1. 25 Jun, 2020 40 commits
    • Pavel Machek (CIP)'s avatar
      ASoC: meson: add missing free_irq() in error path · e6fe402e
      Pavel Machek (CIP) authored
      [ Upstream commit 3b8a299a ]
      
      free_irq() is missing in case of error, fix that.
      Signed-off-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Reviewed-by: default avatarJerome Brunet <jbrunet@baylibre.com>
      
      Link: https://lore.kernel.org/r/20200606153103.GA17905@amdSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6fe402e
    • Mauricio Faria de Oliveira's avatar
      apparmor: check/put label on apparmor_sk_clone_security() · 70fa5992
      Mauricio Faria de Oliveira authored
      [ Upstream commit 3b646abc ]
      
      Currently apparmor_sk_clone_security() does not check for existing
      label/peer in the 'new' struct sock; it just overwrites it, if any
      (with another reference to the label of the source sock.)
      
          static void apparmor_sk_clone_security(const struct sock *sk,
                                                 struct sock *newsk)
          {
                  struct aa_sk_ctx *ctx = SK_CTX(sk);
                  struct aa_sk_ctx *new = SK_CTX(newsk);
      
                  new->label = aa_get_label(ctx->label);
                  new->peer = aa_get_label(ctx->peer);
          }
      
      This might leak label references, which might overflow under load.
      Thus, check for and put labels, to prevent such errors.
      
      Note this is similarly done on:
      
          static int apparmor_socket_post_create(struct socket *sock, ...)
          ...
                  if (sock->sk) {
                          struct aa_sk_ctx *ctx = SK_CTX(sock->sk);
      
                          aa_put_label(ctx->label);
                          ctx->label = aa_get_label(label);
                  }
          ...
      
      Context:
      -------
      
      The label reference count leak is observed if apparmor_sock_graft()
      is called previously: this sets the 'ctx->label' field by getting
      a reference to the current label (later overwritten, without put.)
      
          static void apparmor_sock_graft(struct sock *sk, ...)
          {
                  struct aa_sk_ctx *ctx = SK_CTX(sk);
      
                  if (!ctx->label)
                          ctx->label = aa_get_current_label();
          }
      
      And that is the case on crypto/af_alg.c:af_alg_accept():
      
          int af_alg_accept(struct sock *sk, struct socket *newsock, ...)
          ...
                  struct sock *sk2;
                  ...
                  sk2 = sk_alloc(...);
                  ...
                  security_sock_graft(sk2, newsock);
                  security_sk_clone(sk, sk2);
          ...
      
      Apparently both calls are done on their own right, especially for
      other LSMs, being introduced in 2010/2014, before apparmor socket
      mediation in 2017 (see commits [1,2,3,4]).
      
      So, it looks OK there! Let's fix the reference leak in apparmor.
      
      Test-case:
      ---------
      
      Exercise that code path enough to overflow label reference count.
      
          $ cat aa-refcnt-af_alg.c
          #include <stdio.h>
          #include <string.h>
          #include <unistd.h>
          #include <sys/socket.h>
          #include <linux/if_alg.h>
      
          int main() {
                  int sockfd;
                  struct sockaddr_alg sa;
      
                  /* Setup the crypto API socket */
                  sockfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
                  if (sockfd < 0) {
                          perror("socket");
                          return 1;
                  }
      
                  memset(&sa, 0, sizeof(sa));
                  sa.salg_family = AF_ALG;
                  strcpy((char *) sa.salg_type, "rng");
                  strcpy((char *) sa.salg_name, "stdrng");
      
                  if (bind(sockfd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
                          perror("bind");
                          return 1;
                  }
      
                  /* Accept a "connection" and close it; repeat. */
                  while (!close(accept(sockfd, NULL, 0)));
      
                  return 0;
          }
      
          $ gcc -o aa-refcnt-af_alg aa-refcnt-af_alg.c
      
          $ ./aa-refcnt-af_alg
          <a few hours later>
      
          [ 9928.475953] refcount_t overflow at apparmor_sk_clone_security+0x37/0x70 in aa-refcnt-af_alg[1322], uid/euid: 1000/1000
          ...
          [ 9928.507443] RIP: 0010:apparmor_sk_clone_security+0x37/0x70
          ...
          [ 9928.514286]  security_sk_clone+0x33/0x50
          [ 9928.514807]  af_alg_accept+0x81/0x1c0 [af_alg]
          [ 9928.516091]  alg_accept+0x15/0x20 [af_alg]
          [ 9928.516682]  SYSC_accept4+0xff/0x210
          [ 9928.519609]  SyS_accept+0x10/0x20
          [ 9928.520190]  do_syscall_64+0x73/0x130
          [ 9928.520808]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      
      Note that other messages may be seen, not just overflow, depending on
      the value being incremented by kref_get(); on another run:
      
          [ 7273.182666] refcount_t: saturated; leaking memory.
          ...
          [ 7273.185789] refcount_t: underflow; use-after-free.
      
      Kprobes:
      -------
      
      Using kprobe events to monitor sk -> sk_security -> label -> count (kref):
      
      Original v5.7 (one reference leak every iteration)
      
       ... (af_alg_accept+0x0/0x1c0) label=0xffff8a0f36c25eb0 label_refcnt=0x11fd2
       ... (af_alg_release_parent+0x0/0xd0) label=0xffff8a0f36c25eb0 label_refcnt=0x11fd4
       ... (af_alg_accept+0x0/0x1c0) label=0xffff8a0f36c25eb0 label_refcnt=0x11fd3
       ... (af_alg_release_parent+0x0/0xd0) label=0xffff8a0f36c25eb0 label_refcnt=0x11fd5
       ... (af_alg_accept+0x0/0x1c0) label=0xffff8a0f36c25eb0 label_refcnt=0x11fd4
       ... (af_alg_release_parent+0x0/0xd0) label=0xffff8a0f36c25eb0 label_refcnt=0x11fd6
      
      Patched v5.7 (zero reference leak per iteration)
      
       ... (af_alg_accept+0x0/0x1c0) label=0xffff9ff376c25eb0 label_refcnt=0x593
       ... (af_alg_release_parent+0x0/0xd0) label=0xffff9ff376c25eb0 label_refcnt=0x594
       ... (af_alg_accept+0x0/0x1c0) label=0xffff9ff376c25eb0 label_refcnt=0x593
       ... (af_alg_release_parent+0x0/0xd0) label=0xffff9ff376c25eb0 label_refcnt=0x594
       ... (af_alg_accept+0x0/0x1c0) label=0xffff9ff376c25eb0 label_refcnt=0x593
       ... (af_alg_release_parent+0x0/0xd0) label=0xffff9ff376c25eb0 label_refcnt=0x594
      
      Commits:
      -------
      
      [1] commit 507cad35 ("crypto: af_alg - Make sure sk_security is initialized on accept()ed sockets")
      [2] commit 4c63f83c ("crypto: af_alg - properly label AF_ALG socket")
      [3] commit 2acce6aa ("Networking") a.k.a ("crypto: af_alg - Avoid sock_graft call warning)
      [4] commit 56974a6f ("apparmor: add base infastructure for socket mediation")
      
      Fixes: 56974a6f ("apparmor: add base infastructure for socket mediation")
      Reported-by: default avatarBrian Moyles <bmoyles@netflix.com>
      Signed-off-by: default avatarMauricio Faria de Oliveira <mfo@canonical.com>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      70fa5992
    • John Johansen's avatar
      apparmor: fix introspection of of task mode for unconfined tasks · 86396a49
      John Johansen authored
      [ Upstream commit dd2569fb ]
      
      Fix two issues with introspecting the task mode.
      
      1. If a task is attached to a unconfined profile that is not the
         ns->unconfined profile then. Mode the mode is always reported
         as -
      
            $ ps -Z
            LABEL                               PID TTY          TIME CMD
            unconfined                         1287 pts/0    00:00:01 bash
            test (-)                           1892 pts/0    00:00:00 ps
      
         instead of the correct value of (unconfined) as shown below
      
            $ ps -Z
            LABEL                               PID TTY          TIME CMD
            unconfined                         2483 pts/0    00:00:01 bash
            test (unconfined)                  3591 pts/0    00:00:00 ps
      
      2. if a task is confined by a stack of profiles that are unconfined
         the output of label mode is again the incorrect value of (-) like
         above, instead of (unconfined). This is because the visibile
         profile count increment is skipped by the special casing of
         unconfined.
      
      Fixes: f1bd9041 ("apparmor: add the base fns() for domain labels")
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      86396a49
    • ashimida's avatar
      mksysmap: Fix the mismatch of '.L' symbols in System.map · e71c1098
      ashimida authored
      [ Upstream commit 72d24acc ]
      
      When System.map was generated, the kernel used mksysmap to
      filter the kernel symbols, but all the symbols with the
      second letter 'L' in the kernel were filtered out, not just
      the symbols starting with 'dot + L'.
      
      For example:
      ashimida@ubuntu:~/linux$ cat System.map |grep ' .L'
      ashimida@ubuntu:~/linux$ nm -n vmlinux |grep ' .L'
      ffff0000088028e0 t bLength_show
      ......
      ffff0000092e0408 b PLLP_OUTC_lock
      ffff0000092e0410 b PLLP_OUTA_lock
      
      The original intent should be to filter out all local symbols
      starting with '.L', so the dot should be escaped.
      
      Fixes: 00902e98 ("mksysmap: Add h8300 local symbol pattern")
      Signed-off-by: default avatarashimida <ashimida@linux.alibaba.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e71c1098
    • Logan Gunthorpe's avatar
      NTB: Fix the default port and peer numbers for legacy drivers · f6328a0b
      Logan Gunthorpe authored
      [ Upstream commit fc8b086d ]
      
      When the commit adding ntb_default_port_number() and
      ntb_default_peer_port_number()  entered the kernel there was no
      users of it so it was impossible to tell what the API needed.
      
      When a user finally landed a year later (ntb_pingpong) there were
      more NTB topologies were created and no consideration was considered
      to how other drivers had changed.
      
      Now that there is a user it can be fixed to provide a sensible default
      for the legacy drivers that do not implement ntb_{peer_}port_number().
      Seeing ntb_pingpong doesn't check error codes returning EINVAL was also
      not sensible.
      
      Patches for ntb_pingpong and ntb_perf follow (which are broken
      otherwise) to support hardware that doesn't have port numbers. This is
      important not only to not break support with existing drivers but for
      the cross link topology which, due to its perfect symmetry, cannot
      assign unique port numbers to each side.
      
      Fixes: 1e530119 ("NTB: Add indexed ports NTB API")
      Signed-off-by: default avatarLogan Gunthorpe <logang@deltatee.com>
      Acked-by: default avatarAllen Hubbe <allenbh@gmail.com>
      Tested-by: default avatarAlexander Fomichev <fomichev.ru@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f6328a0b
    • Logan Gunthorpe's avatar
      NTB: ntb_pingpong: Choose doorbells based on port number · ce8280b1
      Logan Gunthorpe authored
      [ Upstream commit ca93c457 ]
      
      This commit fixes pingpong support for existing drivers that do not
      implement ntb_default_port_number() and ntb_default_peer_port_number().
      This is required for hardware (like the crosslink topology of
      switchtec) which cannot assign reasonable port numbers to each port due
      to its perfect symmetry.
      
      Instead of picking the doorbell to use based on the the index of the
      peer, we use the peer's port number. This is a bit clearer and easier
      to understand.
      
      Fixes: c7aeb0af ("NTB: ntb_pp: Add full multi-port NTB API support")
      Signed-off-by: default avatarLogan Gunthorpe <logang@deltatee.com>
      Acked-by: default avatarAllen Hubbe <allenbh@gmail.com>
      Tested-by: default avatarAlexander Fomichev <fomichev.ru@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce8280b1
    • Wang Hai's avatar
      yam: fix possible memory leak in yam_init_driver · 2c75b5c3
      Wang Hai authored
      [ Upstream commit 98749b71 ]
      
      If register_netdev(dev) fails, free_netdev(dev) needs
      to be called, otherwise a memory leak will occur.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2c75b5c3
    • Navid Emamdoost's avatar
      pwm: img: Call pm_runtime_put() in pm_runtime_get_sync() failed case · 97c36deb
      Navid Emamdoost authored
      [ Upstream commit ca162ce9 ]
      
      Even in failed case of pm_runtime_get_sync(), the usage_count is
      incremented. In order to keep the usage_count with correct value call
      appropriate pm_runtime_put().
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      97c36deb
    • Pingfan Liu's avatar
      powerpc/crashkernel: Take "mem=" option into account · 78c131f6
      Pingfan Liu authored
      [ Upstream commit be5470e0 ]
      
      'mem=" option is an easy way to put high pressure on memory during
      some test. Hence after applying the memory limit, instead of total
      mem, the actual usable memory should be considered when reserving mem
      for crashkernel. Otherwise the boot up may experience OOM issue.
      
      E.g. it would reserve 4G prior to the change and 512M afterward, if
      passing
      crashkernel="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G",
      and mem=5G on a 256G machine.
      
      This issue is powerpc specific because it puts higher priority on
      fadump and kdump reservation than on "mem=". Referring the following
      code:
          if (fadump_reserve_mem() == 0)
                  reserve_crashkernel();
          ...
          /* Ensure that total memory size is page-aligned. */
          limit = ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SIZE);
          memblock_enforce_memory_limit(limit);
      
      While on other arches, the effect of "mem=" takes a higher priority
      and pass through memblock_phys_mem_size() before calling
      reserve_crashkernel().
      Signed-off-by: default avatarPingfan Liu <kernelfans@gmail.com>
      Reviewed-by: default avatarHari Bathini <hbathini@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1585749644-4148-1-git-send-email-kernelfans@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      78c131f6
    • Jon Derrick's avatar
      PCI: vmd: Filter resource type bits from shadow register · 8861d95c
      Jon Derrick authored
      [ Upstream commit 3e5095ee ]
      
      Versions of VMD with the Host Physical Address shadow register use this
      register to calculate the bus address offset needed to do guest
      passthrough of the domain. This register shadows the Host Physical
      Address registers including the resource type bits. After calculating
      the offset, the extra resource type bits lead to the VMD resources being
      over-provisioned at the front and under-provisioned at the back.
      
      Example:
      pci 10000:80:02.0: reg 0x10: [mem 0xf801fffc-0xf803fffb 64bit]
      
      Expected:
      pci 10000:80:02.0: reg 0x10: [mem 0xf8020000-0xf803ffff 64bit]
      
      If other devices are mapped in the over-provisioned front, it could lead
      to resource conflict issues with VMD or those devices.
      
      Link: https://lore.kernel.org/r/20200528030240.16024-3-jonathan.derrick@intel.com
      Fixes: a1a30170 ("PCI: vmd: Fix shadow offsets to reflect spec changes")
      Signed-off-by: default avatarJon Derrick <jonathan.derrick@intel.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8861d95c
    • Xiyu Yang's avatar
      nfsd: Fix svc_xprt refcnt leak when setup callback client failed · 22c72156
      Xiyu Yang authored
      [ Upstream commit a4abc6b1 ]
      
      nfsd4_process_cb_update() invokes svc_xprt_get(), which increases the
      refcount of the "c->cn_xprt".
      
      The reference counting issue happens in one exception handling path of
      nfsd4_process_cb_update(). When setup callback client failed, the
      function forgets to decrease the refcnt increased by svc_xprt_get(),
      causing a refcnt leak.
      
      Fix this issue by calling svc_xprt_put() when setup callback client
      failed.
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      22c72156
    • Kajol Jain's avatar
      powerpc/perf/hv-24x7: Fix inconsistent output values incase multiple hv-24x7 events run · 4b2f2a38
      Kajol Jain authored
      [ Upstream commit b4ac18ee ]
      
      Commit 2b206ee6 ("powerpc/perf/hv-24x7: Display change in counter
      values")' added to print _change_ in the counter value rather then raw
      value for 24x7 counters. Incase of transactions, the event count
      is set to 0 at the beginning of the transaction. It also sets
      the event's prev_count to the raw value at the time of initialization.
      Because of setting event count to 0, we are seeing some weird behaviour,
      whenever we run multiple 24x7 events at a time.
      
      For example:
      
      command#: ./perf stat -e "{hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/,
      			   hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/}"
      	  		   -C 0 -I 1000 sleep 100
      
           1.000121704                120 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           1.000121704                  5 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           2.000357733                  8 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           2.000357733                 10 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           3.000495215 18,446,744,073,709,551,616 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           3.000495215 18,446,744,073,709,551,616 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           4.000641884                 56 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           4.000641884 18,446,744,073,709,551,616 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           5.000791887 18,446,744,073,709,551,616 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
      
      Getting these large values in case we do -I.
      
      As we are setting event_count to 0, for interval case, overall event_count is not
      coming in incremental order. As we may can get new delta lesser then previous count.
      Because of which when we print intervals, we are getting negative value which create
      these large values.
      
      This patch removes part where we set event_count to 0 in function
      'h_24x7_event_read'. There won't be much impact as we do set event->hw.prev_count
      to the raw value at the time of initialization to print change value.
      
      With this patch
      In power9 platform
      
      command#: ./perf stat -e "{hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/,
      		           hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/}"
      			   -C 0 -I 1000 sleep 100
      
           1.000117685                 93 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           1.000117685                  1 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           2.000349331                 98 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           2.000349331                  2 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           3.000495900                131 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           3.000495900                  4 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           4.000645920                204 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
           4.000645920                 61 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=1/
           4.284169997                 22 hv_24x7/PM_MCS01_128B_RD_DISP_PORT01,chip=0/
      Suggested-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Tested-by: default avatarMadhavan Srinivasan <maddy@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200525104308.9814-2-kjain@linux.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      4b2f2a38
    • Alain Volmat's avatar
      clk: clk-flexgen: fix clock-critical handling · f59c4d14
      Alain Volmat authored
      [ Upstream commit a403bbab ]
      
      Fixes an issue leading to having all clocks following a critical
      clocks marked as well as criticals.
      
      Fixes: fa6415af ("clk: st: clk-flexgen: Detect critical clocks")
      Signed-off-by: default avatarAlain Volmat <avolmat@me.com>
      Link: https://lkml.kernel.org/r/20200322140740.3970-1-avolmat@me.comReviewed-by: default avatarPatrice Chotard <patrice.chotard@st.com>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f59c4d14
    • Xiyu Yang's avatar
      scsi: lpfc: Fix lpfc_nodelist leak when processing unsolicited event · b3cad8af
      Xiyu Yang authored
      [ Upstream commit 7217e6e6 ]
      
      In order to create or activate a new node, lpfc_els_unsol_buffer() invokes
      lpfc_nlp_init() or lpfc_enable_node() or lpfc_nlp_get(), all of them will
      return a reference of the specified lpfc_nodelist object to "ndlp" with
      increased refcnt.
      
      When lpfc_els_unsol_buffer() returns, local variable "ndlp" becomes
      invalid, so the refcount should be decreased to keep refcount balanced.
      
      The reference counting issue happens in one exception handling path of
      lpfc_els_unsol_buffer(). When "ndlp" in DEV_LOSS, the function forgets to
      decrease the refcnt increased by lpfc_nlp_init() or lpfc_enable_node() or
      lpfc_nlp_get(), causing a refcnt leak.
      
      Fix this issue by calling lpfc_nlp_put() when "ndlp" in DEV_LOSS.
      
      Link: https://lore.kernel.org/r/1590416184-52592-1-git-send-email-xiyuyang19@fudan.edu.cnReviewed-by: default avatarDaniel Wagner <dwagner@suse.de>
      Reviewed-by: default avatarJames Smart <james.smart@broadcom.com>
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b3cad8af
    • Marek Szyprowski's avatar
      mfd: wm8994: Fix driver operation if loaded as modules · e3f5b9a3
      Marek Szyprowski authored
      [ Upstream commit d4f9b542 ]
      
      WM8994 chip has built-in regulators, which might be used for chip
      operation. They are controlled by a separate wm8994-regulator driver,
      which should be loaded before this driver calls regulator_get(), because
      that driver also provides consumer-supply mapping for the them. If that
      driver is not yet loaded, regulator core substitute them with dummy
      regulator, what breaks chip operation, because the built-in regulators are
      never enabled. Fix this by annotating this driver with MODULE_SOFTDEP()
      "pre" dependency to "wm8994_regulator" module.
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3f5b9a3
    • Andy Shevchenko's avatar
      gpio: dwapb: Call acpi_gpiochip_free_interrupts() on GPIO chip de-registration · 3bb97b7d
      Andy Shevchenko authored
      [ Upstream commit 494a94e3 ]
      
      Add missed acpi_gpiochip_free_interrupts() call when unregistering ports.
      
      While at it, drop extra check to call acpi_gpiochip_request_interrupts().
      There is no need to have an additional check to call
      acpi_gpiochip_request_interrupts(). Even without any interrupts available
      the registered ACPI Event handlers can be useful for debugging purposes.
      
      Fixes: e6cb3486 ("gpio: dwapb: add gpio-signaled acpi event support")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Tested-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Acked-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Link: https://lore.kernel.org/r/20200519131233.59032-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3bb97b7d
    • Christophe JAILLET's avatar
      m68k/PCI: Fix a memory leak in an error handling path · 1bcf9749
      Christophe JAILLET authored
      [ Upstream commit c3f4ec05 ]
      
      If 'ioremap' fails, we must free 'bridge', as done in other error handling
      path bellow.
      
      Fixes: 19cc4c84 ("m68k/PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1bcf9749
    • Aharon Landau's avatar
      RDMA/mlx5: Add init2init as a modify command · e70fd099
      Aharon Landau authored
      [ Upstream commit 819f7427 ]
      
      Missing INIT2INIT entry in the list of modify commands caused DEVX
      applications to be unable to modify_qp for this transition state. Add the
      MLX5_CMD_OP_INIT2INIT_QP opcode to the list of allowed DEVX opcodes.
      
      Fixes: e662e14d ("IB/mlx5: Add DEVX support for modify and query commands")
      Link: https://lore.kernel.org/r/20200513095550.211345-1-leon@kernel.orgSigned-off-by: default avatarAharon Landau <aharonl@mellanox.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e70fd099
    • Qian Cai's avatar
      vfio/pci: fix memory leaks in alloc_perm_bits() · 78914f16
      Qian Cai authored
      [ Upstream commit 3e63b94b ]
      
      vfio_pci_disable() calls vfio_config_free() but forgets to call
      free_perm_bits() resulting in memory leaks,
      
      unreferenced object 0xc000000c4db2dee0 (size 16):
        comm "qemu-kvm", pid 4305, jiffies 4295020272 (age 3463.780s)
        hex dump (first 16 bytes):
          00 00 ff 00 ff ff ff ff ff ff ff ff ff ff 00 00  ................
        backtrace:
          [<00000000a6a4552d>] alloc_perm_bits+0x58/0xe0 [vfio_pci]
          [<00000000ac990549>] vfio_config_init+0xdf0/0x11b0 [vfio_pci]
          init_pci_cap_msi_perm at drivers/vfio/pci/vfio_pci_config.c:1125
          (inlined by) vfio_msi_cap_len at drivers/vfio/pci/vfio_pci_config.c:1180
          (inlined by) vfio_cap_len at drivers/vfio/pci/vfio_pci_config.c:1241
          (inlined by) vfio_cap_init at drivers/vfio/pci/vfio_pci_config.c:1468
          (inlined by) vfio_config_init at drivers/vfio/pci/vfio_pci_config.c:1707
          [<000000006db873a1>] vfio_pci_open+0x234/0x700 [vfio_pci]
          [<00000000630e1906>] vfio_group_fops_unl_ioctl+0x8e0/0xb84 [vfio]
          [<000000009e34c54f>] ksys_ioctl+0xd8/0x130
          [<000000006577923d>] sys_ioctl+0x28/0x40
          [<000000006d7b1cf2>] system_call_exception+0x114/0x1e0
          [<0000000008ea7dd5>] system_call_common+0xf0/0x278
      unreferenced object 0xc000000c4db2e330 (size 16):
        comm "qemu-kvm", pid 4305, jiffies 4295020272 (age 3463.780s)
        hex dump (first 16 bytes):
          00 ff ff 00 ff ff ff ff ff ff ff ff ff ff 00 00  ................
        backtrace:
          [<000000004c71914f>] alloc_perm_bits+0x44/0xe0 [vfio_pci]
          [<00000000ac990549>] vfio_config_init+0xdf0/0x11b0 [vfio_pci]
          [<000000006db873a1>] vfio_pci_open+0x234/0x700 [vfio_pci]
          [<00000000630e1906>] vfio_group_fops_unl_ioctl+0x8e0/0xb84 [vfio]
          [<000000009e34c54f>] ksys_ioctl+0xd8/0x130
          [<000000006577923d>] sys_ioctl+0x28/0x40
          [<000000006d7b1cf2>] system_call_exception+0x114/0x1e0
          [<0000000008ea7dd5>] system_call_common+0xf0/0x278
      
      Fixes: 89e1f7d4 ("vfio: Add PCI device driver")
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      [aw: rolled in follow-up patch]
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      78914f16
    • Emmanuel Nicolet's avatar
      ps3disk: use the default segment boundary · 302f0c5e
      Emmanuel Nicolet authored
      [ Upstream commit 720bc316 ]
      
      Since commit dcebd755 ("block: use bio_for_each_bvec() to compute
      multi-page bvec count"), the kernel will bug_on on the PS3 because
      bio_split() is called with sectors == 0:
      
        kernel BUG at block/bio.c:1853!
        Oops: Exception in kernel mode, sig: 5 [#1]
        BE PAGE_SIZE=4K MMU=Hash PREEMPT SMP NR_CPUS=8 NUMA PS3
        Modules linked in: firewire_sbp2 rtc_ps3(+) soundcore ps3_gelic(+) \
        ps3rom(+) firewire_core ps3vram(+) usb_common crc_itu_t
        CPU: 0 PID: 97 Comm: blkid Not tainted 5.3.0-rc4 #1
        NIP:  c00000000027d0d0 LR: c00000000027d0b0 CTR: 0000000000000000
        REGS: c00000000135ae90 TRAP: 0700   Not tainted  (5.3.0-rc4)
        MSR:  8000000000028032 <SF,EE,IR,DR,RI>  CR: 44008240  XER: 20000000
        IRQMASK: 0
        GPR00: c000000000289368 c00000000135b120 c00000000084a500 c000000004ff8300
        GPR04: 0000000000000c00 c000000004c905e0 c000000004c905e0 000000000000ffff
        GPR08: 0000000000000000 0000000000000001 0000000000000000 000000000000ffff
        GPR12: 0000000000000000 c0000000008ef000 000000000000003e 0000000000080001
        GPR16: 0000000000000100 000000000000ffff 0000000000000000 0000000000000004
        GPR20: c00000000062fd7e 0000000000000001 000000000000ffff 0000000000000080
        GPR24: c000000000781788 c00000000135b350 0000000000000080 c000000004c905e0
        GPR28: c00000000135b348 c000000004ff8300 0000000000000000 c000000004c90000
        NIP [c00000000027d0d0] .bio_split+0x28/0xac
        LR [c00000000027d0b0] .bio_split+0x8/0xac
        Call Trace:
        [c00000000135b120] [c00000000027d130] .bio_split+0x88/0xac (unreliable)
        [c00000000135b1b0] [c000000000289368] .__blk_queue_split+0x11c/0x53c
        [c00000000135b2d0] [c00000000028f614] .blk_mq_make_request+0x80/0x7d4
        [c00000000135b3d0] [c000000000283a8c] .generic_make_request+0x118/0x294
        [c00000000135b4b0] [c000000000283d34] .submit_bio+0x12c/0x174
        [c00000000135b580] [c000000000205a44] .mpage_bio_submit+0x3c/0x4c
        [c00000000135b600] [c000000000206184] .mpage_readpages+0xa4/0x184
        [c00000000135b750] [c0000000001ff8fc] .blkdev_readpages+0x24/0x38
        [c00000000135b7c0] [c0000000001589f0] .read_pages+0x6c/0x1a8
        [c00000000135b8b0] [c000000000158c74] .__do_page_cache_readahead+0x118/0x184
        [c00000000135b9b0] [c0000000001591a8] .force_page_cache_readahead+0xe4/0xe8
        [c00000000135ba50] [c00000000014fc24] .generic_file_read_iter+0x1d8/0x830
        [c00000000135bb50] [c0000000001ffadc] .blkdev_read_iter+0x40/0x5c
        [c00000000135bbc0] [c0000000001b9e00] .new_sync_read+0x144/0x1a0
        [c00000000135bcd0] [c0000000001bc454] .vfs_read+0xa0/0x124
        [c00000000135bd70] [c0000000001bc7a4] .ksys_read+0x70/0xd8
        [c00000000135be20] [c00000000000a524] system_call+0x5c/0x70
        Instruction dump:
        7fe3fb78 482e30dc 7c0802a6 482e3085 7c9e2378 f821ff71 7ca42b78 7d3e00d0
        7c7d1b78 79290fe0 7cc53378 69290001 <0b090000> 81230028 7bca0020 7929ba62
        [ end trace 313fec760f30aa1f ]---
      
      The problem originates from setting the segment boundary of the
      request queue to -1UL. This makes get_max_segment_size() return zero
      when offset is zero, whatever the max segment size. The test with
      BLK_SEG_BOUNDARY_MASK fails and 'mask - (mask & offset) + 1' overflows
      to zero in the return statement.
      
      Not setting the segment boundary and using the default
      value (BLK_SEG_BOUNDARY_MASK) fixes the problem.
      Signed-off-by: default avatarEmmanuel Nicolet <emmanuel.nicolet@gmail.com>
      Signed-off-by: default avatarGeoff Levand <geoff@infradead.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/060a416c43138f45105c0540eff1a45539f7e2fc.1589049250.git.geoff@infradead.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      302f0c5e
    • Pali Rohár's avatar
      PCI: aardvark: Don't blindly enable ASPM L0s and don't write to read-only register · bee54028
      Pali Rohár authored
      [ Upstream commit 90c6cb4a ]
      
      Trying to change Link Status register does not have any effect as this
      is a read-only register. Trying to overwrite bits for Negotiated Link
      Width does not make sense.
      
      In future proper change of link width can be done via Lane Count Select
      bits in PCIe Control 0 register.
      
      Trying to unconditionally enable ASPM L0s via ASPM Control bits in Link
      Control register is wrong. There should be at least some detection if
      endpoint supports L0s as isn't mandatory.
      
      Moreover ASPM Control bits in Link Control register are controlled by
      pcie/aspm.c code which sets it according to system ASPM settings,
      immediately after aardvark driver probes. So setting these bits by
      aardvark driver has no long running effect.
      
      Remove code which touches ASPM L0s bits from this driver and let
      kernel's ASPM implementation to set ASPM state properly.
      
      Some users are reporting issues that this code is problematic for some
      Intel wifi cards and removing it fixes them, see e.g.:
      https://bugzilla.kernel.org/show_bug.cgi?id=196339
      
      If problems with Intel wifi cards occur even after this commit, then
      pcie/aspm.c code could be modified / hooked to not enable ASPM L0s state
      for affected problematic cards.
      
      Link: https://lore.kernel.org/r/20200430080625.26070-3-pali@kernel.orgTested-by: default avatarTomasz Maciej Nowak <tmn505@gmail.com>
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Acked-by: default avatarThomas Petazzoni <thomas.petazzoni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bee54028
    • Martin Wilck's avatar
      dm mpath: switch paths in dm_blk_ioctl() code path · 49306a3e
      Martin Wilck authored
      [ Upstream commit 2361ae59 ]
      
      SCSI LUN passthrough code such as qemu's "scsi-block" device model
      pass every IO to the host via SG_IO ioctls. Currently, dm-multipath
      calls choose_pgpath() only in the block IO code path, not in the ioctl
      code path (unless current_pgpath is NULL). This has the effect that no
      path switching and thus no load balancing is done for SCSI-passthrough
      IO, unless the active path fails.
      
      Fix this by using the same logic in multipath_prepare_ioctl() as in
      multipath_clone_and_map().
      
      Note: The allegedly best path selection algorithm, service-time,
      still wouldn't work perfectly, because the io size of the current
      request is always set to 0. Changing that for the IO passthrough
      case would require the ioctl cmd and arg to be passed to dm's
      prepare_ioctl() method.
      Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      49306a3e
    • Serge Semin's avatar
      serial: 8250: Fix max baud limit in generic 8250 port · 0eeaf629
      Serge Semin authored
      [ Upstream commit 7b668c06 ]
      
      Standard 8250 UART ports are designed in a way so they can communicate
      with baud rates up to 1/16 of a reference frequency. It's expected from
      most of the currently supported UART controllers. That's why the former
      version of serial8250_get_baud_rate() method called uart_get_baud_rate()
      with min and max baud rates passed as (port->uartclk / 16 / UART_DIV_MAX)
      and ((port->uartclk + tolerance) / 16) respectively. Doing otherwise, like
      it was suggested in commit ("serial: 8250_mtk: support big baud rate."),
      caused acceptance of bauds, which was higher than the normal UART
      controllers actually supported. As a result if some user-space program
      requested to set a baud greater than (uartclk / 16) it would have been
      permitted without truncation, but then serial8250_get_divisor(baud)
      (which calls uart_get_divisor() to get the reference clock divisor) would
      have returned a zero divisor. Setting zero divisor will cause an
      unpredictable effect varying from chip to chip. In case of DW APB UART the
      communications just stop.
      
      Lets fix this problem by getting back the limitation of (uartclk +
      tolerance) / 16 maximum baud supported by the generic 8250 port. Mediatek
      8250 UART ports driver developer shouldn't have touched it in the first
      place  notably seeing he already provided a custom version of set_termios()
      callback in that glue-driver which took into account the extended baud
      rate values and accordingly updated the standard and vendor-specific
      divisor latch registers anyway.
      
      Fixes: 81bb549f ("serial: 8250_mtk: support big baud rate.")
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Long Cheng <long.cheng@mediatek.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-mediatek@lists.infradead.org
      Link: https://lore.kernel.org/r/20200506233136.11842-2-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0eeaf629
    • Oliver Neukum's avatar
      usblp: poison URBs upon disconnect · 04519854
      Oliver Neukum authored
      [ Upstream commit 296a193b ]
      
      syzkaller reported an URB that should have been killed to be active.
      We do not understand it, but this should fix the issue if it is real.
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Reported-by: syzbot+be5b5f86a162a6c281e6@syzkaller.appspotmail.com
      Link: https://lore.kernel.org/r/20200507085806.5793-1-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04519854
    • Marek Szyprowski's avatar
      clk: samsung: Mark top ISP and CAM clocks on Exynos542x as critical · aba4a507
      Marek Szyprowski authored
      [ Upstream commit e47bd937 ]
      
      The TOP 'aclk*_isp', 'aclk550_cam', 'gscl_wa' and 'gscl_wb' clocks must
      be kept enabled all the time to allow proper access to power management
      control for the ISP and CAM power domains. The last two clocks, although
      related to GScaler device and GSCL power domain, provides also the
      I_WRAP_CLK signal to MIPI CSIS0/1 devices, which are a part of CAM power
      domain and are needed for proper power on/off sequence.
      
      Currently there are no drivers for the devices, which are part of CAM and
      ISP power domains yet. This patch only fixes the race between disabling
      the unused power domains and disabling unused clocks, which randomly
      resulted in the following error during boot:
      
      Power domain CAM disable failed
      Power domain ISP disable failed
      
      Fixes: 318fa46c ("clk/samsung: exynos542x: mark some clocks as critical")
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Acked-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aba4a507
    • Russell King's avatar
      i2c: pxa: clear all master action bits in i2c_pxa_stop_message() · 3018d81c
      Russell King authored
      [ Upstream commit e81c979f ]
      
      If we timeout during a message transfer, the control register may
      contain bits that cause an action to be set. Read-modify-writing the
      register leaving these bits set may trigger the hardware to attempt
      one of these actions unintentionally.
      
      Always clear these bits when cleaning up after a message or after
      a timeout.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3018d81c
    • Konstantin Khlebnikov's avatar
      f2fs: report delalloc reserve as non-free in statfs for project quota · 9ecdbfee
      Konstantin Khlebnikov authored
      [ Upstream commit baaa7ebf ]
      
      This reserved space isn't committed yet but cannot be used for
      allocations. For userspace it has no difference from used space.
      
      See the same fix in ext4 commit f06925c7 ("ext4: report delalloc
      reserve as non-free in statfs for project quota").
      
      Fixes: ddc34e32 ("f2fs: introduce f2fs_statfs_project")
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ecdbfee
    • Andreas Klinger's avatar
      iio: bmp280: fix compensation of humidity · 89d3d21b
      Andreas Klinger authored
      [ Upstream commit dee2dabc ]
      
      Limit the output of humidity compensation to the range between 0 and 100
      percent.
      
      Depending on the calibration parameters of the individual sensor it
      happens, that a humidity above 100 percent or below 0 percent is
      calculated, which don't make sense in terms of relative humidity.
      
      Add a clamp to the compensation formula as described in the datasheet of
      the sensor in chapter 4.2.3.
      
      Although this clamp is documented, it was never in the driver of the
      kernel.
      
      It depends on the circumstances (calibration parameters, temperature,
      humidity) if one can see a value above 100 percent without the clamp.
      The writer of this patch was working with this type of sensor without
      noting this error. So it seems to be a rare event when this bug occures.
      Signed-off-by: default avatarAndreas Klinger <ak@it-klinger.de>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      89d3d21b
    • Viacheslav Dubeyko's avatar
      scsi: qla2xxx: Fix issue with adapter's stopping state · 63ec23f6
      Viacheslav Dubeyko authored
      [ Upstream commit 803e4555 ]
      
      The goal of the following command sequence is to restart the adapter.
      However, the tgt_stop flag remains set, indicating that the adapter is
      still in stopping state even after re-enabling it.
      
      echo 0x7fffffff > /sys/module/qla2xxx/parameters/logging
      modprobe target_core_mod
      modprobe tcm_qla2xxx
      mkdir /sys/kernel/config/target/qla2xxx
      mkdir /sys/kernel/config/target/qla2xxx/<port-name>
      mkdir /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1
      echo 1 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
      echo 0 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
      echo 1 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
      
      kernel: PID 1396:qla_target.c:1555 qlt_stop_phase1(): tgt_stop 0x0, tgt_stopped 0x0
      kernel: qla2xxx [0001:00:02.0]-e803:1: PID 1396:qla_target.c:1567: Stopping target for host 1(c0000000033557e8)
      kernel: PID 1396:qla_target.c:1579 qlt_stop_phase1(): tgt_stop 0x1, tgt_stopped 0x0
      kernel: PID 1396:qla_target.c:1266 qlt_schedule_sess_for_deletion(): tgt_stop 0x1, tgt_stopped 0x0
      kernel: qla2xxx [0001:00:02.0]-e801:1: PID 1396:qla_target.c:1316: Scheduling sess c00000002d5cd800 for deletion 21:00:00:24:ff:7f:35:c7
      <skipped>
      kernel: qla2xxx [0001:00:02.0]-290a:1: PID 340:qla_target.c:1187: qlt_unreg_sess sess c00000002d5cd800 for deletion 21:00:00:24:ff:7f:35:c7
      <skipped>
      kernel: qla2xxx [0001:00:02.0]-f801:1: PID 340:qla_target.c:1145: Unregistration of sess c00000002d5cd800 21:00:00:24:ff:7f:35:c7 finished fcp_cnt 0
      kernel: PID 340:qla_target.c:1155 qlt_free_session_done(): tgt_stop 0x1, tgt_stopped 0x0
      kernel: qla2xxx [0001:00:02.0]-4807:1: PID 346:qla_os.c:6329: ISP abort scheduled.
      <skipped>
      kernel: qla2xxx [0001:00:02.0]-28f1:1: PID 346:qla_os.c:3956: Mark all dev lost
      kernel: PID 346:qla_target.c:1266 qlt_schedule_sess_for_deletion(): tgt_stop 0x1, tgt_stopped 0x0
      kernel: qla2xxx [0001:00:02.0]-4808:1: PID 346:qla_os.c:6338: ISP abort end.
      <skipped>
      kernel: PID 1396:qla_target.c:6812 qlt_enable_vha(): tgt_stop 0x1, tgt_stopped 0x0
      <skipped>
      kernel: qla2xxx [0001:00:02.0]-4807:1: PID 346:qla_os.c:6329: ISP abort scheduled.
      <skipped>
      kernel: qla2xxx [0001:00:02.0]-4808:1: PID 346:qla_os.c:6338: ISP abort end.
      
      qlt_handle_cmd_for_atio() rejects the request to send commands because the
      adapter is in the stopping state:
      
      kernel: PID 0:qla_target.c:4442 qlt_handle_cmd_for_atio(): tgt_stop 0x1, tgt_stopped 0x0
      kernel: qla2xxx [0001:00:02.0]-3861:1: PID 0:qla_target.c:4447: New command while device c000000005314600 is shutting down
      kernel: qla2xxx [0001:00:02.0]-e85f:1: PID 0:qla_target.c:5728: qla_target: Unable to send command to target
      
      This patch calls qla_stop_phase2() in addition to qlt_stop_phase1() in
      tcm_qla2xxx_tpg_enable_store() and tcm_qla2xxx_npiv_tpg_enable_store(). The
      qlt_stop_phase1() marks adapter as stopping (tgt_stop == 0x1, tgt_stopped
      == 0x0) but qlt_stop_phase2() marks adapter as stopped (tgt_stop == 0x0,
      tgt_stopped == 0x1).
      
      Link: https://lore.kernel.org/r/52be1e8a3537f6c5407eae3edd4c8e08a9545ea5.camel@yadro.comReviewed-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: default avatarViacheslav Dubeyko <v.dubeiko@yadro.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      63ec23f6
    • Ard Biesheuvel's avatar
      PCI: Allow pci_resize_resource() for devices on root bus · f7ec6056
      Ard Biesheuvel authored
      [ Upstream commit d09ddd81 ]
      
      When resizing a BAR, pci_reassign_bridge_resources() is invoked to bring
      the bridge windows of parent bridges in line with the new BAR assignment.
      
      This assumes the device whose BAR is being resized lives on a subordinate
      bus, but this is not necessarily the case. A device may live on the root
      bus, in which case dev->bus->self is NULL, and passing a NULL pci_dev
      pointer to pci_reassign_bridge_resources() will cause it to crash.
      
      So let's make the call to pci_reassign_bridge_resources() conditional on
      whether dev->bus->self is non-NULL in the first place.
      
      Fixes: 8bb705e3 ("PCI: Add pci_resize_resource() for resizing BARs")
      Link: https://lore.kernel.org/r/20200421162256.26887-1-ardb@kernel.orgSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f7ec6056
    • Dan Carpenter's avatar
      ALSA: isa/wavefront: prevent out of bounds write in ioctl · f2ad530b
      Dan Carpenter authored
      [ Upstream commit 7f0d5053 ]
      
      The "header->number" comes from the ioctl and it needs to be clamped to
      prevent out of bounds writes.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20200501094011.GA960082@mwandaSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f2ad530b
    • Kai-Heng Feng's avatar
      ALSA: hda/realtek - Introduce polarity for micmute LED GPIO · c33ee0a0
      Kai-Heng Feng authored
      [ Upstream commit dbd13179 ]
      
      Currently mute LED and micmute LED share the same GPIO polarity.
      
      So split the polarity for mute and micmute, in case they have different
      polarities.
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Link: https://lore.kernel.org/r/20200430083255.5093-1-kai.heng.feng@canonical.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c33ee0a0
    • Dan Carpenter's avatar
      scsi: qedi: Check for buffer overflow in qedi_set_path() · 84ef0da8
      Dan Carpenter authored
      [ Upstream commit 4a4c0cfb ]
      
      Smatch complains that the "path_data->handle" variable is user controlled.
      It comes from iscsi_set_path() so that seems possible.  It's harmless to
      add a limit check.
      
      The qedi->ep_tbl[] array has qedi->max_active_conns elements (which is
      always ISCSI_MAX_SESS_PER_HBA (4096) elements).  The array is allocated in
      the qedi_cm_alloc_mem() function.
      
      Link: https://lore.kernel.org/r/20200428131939.GA696531@mwanda
      Fixes: ace7f46b ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
      Acked-by: default avatarManish Rangankar <mrangankar@marvell.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      84ef0da8
    • Linus Walleij's avatar
      ARM: integrator: Add some Kconfig selections · b9e3114f
      Linus Walleij authored
      [ Upstream commit d2854bbe ]
      
      The CMA and DMA_CMA Kconfig options need to be selected
      by the Integrator in order to produce boot console on some
      Integrator systems.
      
      The REGULATOR and REGULATOR_FIXED_VOLTAGE need to be
      selected in order to boot the system from an external
      MMC card when using MMCI/PL181 from the device tree
      probe path.
      
      Select these things directly from the Kconfig so we are
      sure to be able to bring the systems up with console
      from any device tree.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b9e3114f
    • Xiyu Yang's avatar
      ASoC: davinci-mcasp: Fix dma_chan refcnt leak when getting dma type · 49aa5538
      Xiyu Yang authored
      [ Upstream commit a697ae6e ]
      
      davinci_mcasp_get_dma_type() invokes dma_request_chan(), which returns a
      reference of the specified dma_chan object to "chan" with increased
      refcnt.
      
      When davinci_mcasp_get_dma_type() returns, local variable "chan" becomes
      invalid, so the refcount should be decreased to keep refcount balanced.
      
      The reference counting issue happens in one exception handling path of
      davinci_mcasp_get_dma_type(). When chan device is NULL, the function
      forgets to decrease the refcnt increased by dma_request_chan(), causing
      a refcnt leak.
      
      Fix this issue by calling dma_release_channel() when chan device is
      NULL.
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Acked-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
      Link: https://lore.kernel.org/r/1587818916-38730-1-git-send-email-xiyuyang19@fudan.edu.cnSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      49aa5538
    • Jon Hunter's avatar
      backlight: lp855x: Ensure regulators are disabled on probe failure · 5970f0c9
      Jon Hunter authored
      [ Upstream commit d8207c15 ]
      
      If probing the LP885x backlight fails after the regulators have been
      enabled, then the following warning is seen when releasing the
      regulators ...
      
       WARNING: CPU: 1 PID: 289 at drivers/regulator/core.c:2051 _regulator_put.part.28+0x158/0x160
       Modules linked in: tegra_xudc lp855x_bl(+) host1x pwm_tegra ip_tables x_tables ipv6 nf_defrag_ipv6
       CPU: 1 PID: 289 Comm: systemd-udevd Not tainted 5.6.0-rc2-next-20200224 #1
       Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
      
       ...
      
       Call trace:
        _regulator_put.part.28+0x158/0x160
        regulator_put+0x34/0x50
        devm_regulator_release+0x10/0x18
        release_nodes+0x12c/0x230
        devres_release_all+0x34/0x50
        really_probe+0x1c0/0x370
        driver_probe_device+0x58/0x100
        device_driver_attach+0x6c/0x78
        __driver_attach+0xb0/0xf0
        bus_for_each_dev+0x68/0xc8
        driver_attach+0x20/0x28
        bus_add_driver+0x160/0x1f0
        driver_register+0x60/0x110
        i2c_register_driver+0x40/0x80
        lp855x_driver_init+0x20/0x1000 [lp855x_bl]
        do_one_initcall+0x58/0x1a0
        do_init_module+0x54/0x1d0
        load_module+0x1d80/0x21c8
        __do_sys_finit_module+0xe8/0x100
        __arm64_sys_finit_module+0x18/0x20
        el0_svc_common.constprop.3+0xb0/0x168
        do_el0_svc+0x20/0x98
        el0_sync_handler+0xf4/0x1b0
        el0_sync+0x140/0x180
      
      Fix this by ensuring that the regulators are disabled, if enabled, on
      probe failure.
      
      Finally, ensure that the vddio regulator is disabled in the driver
      remove handler.
      Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5970f0c9
    • Bryan O'Donoghue's avatar
      clk: qcom: msm8916: Fix the address location of pll->config_reg · 4dfedcd4
      Bryan O'Donoghue authored
      [ Upstream commit f47ab3c2 ]
      
      During the process of debugging a processor derived from the msm8916 which
      we found the new processor was not starting one of its PLLs.
      
      After tracing the addresses and writes that downstream was doing and
      comparing to upstream it became obvious that we were writing to a different
      register location than downstream when trying to configure the PLL.
      
      This error is also present in upstream msm8916.
      
      As an example clk-pll.c::clk_pll_recalc_rate wants to write to
      pll->config_reg updating the bit-field POST_DIV_RATIO. That bit-field is
      defined in PLL_USER_CTL not in PLL_CONFIG_CTL. Taking the BIMC PLL as an
      example
      
      lm80-p0436-13_c_qc_snapdragon_410_processor_hrd.pdf
      
      0x01823010 GCC_BIMC_PLL_USER_CTL
      0x01823014 GCC_BIMC_PLL_CONFIG_CTL
      
      This pattern is repeated for gpll0, gpll1, gpll2 and bimc_pll.
      
      This error is likely not apparent since the bootloader will already have
      initialized these PLLs.
      
      This patch corrects the location of config_reg from PLL_CONFIG_CTL to
      PLL_USER_CTL for all relevant PLLs on msm8916.
      
      Fixes commit 3966fab8 ("clk: qcom: Add MSM8916 Global Clock Controller support")
      
      Cc: Georgi Djakov <georgi.djakov@linaro.org>
      Cc: Andy Gross <agross@kernel.org>
      Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Link: https://lkml.kernel.org/r/20200329124116.4185447-1-bryan.odonoghue@linaro.orgSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4dfedcd4
    • Alex Elder's avatar
      remoteproc: Fix IDR initialisation in rproc_alloc() · ef3b1056
      Alex Elder authored
      [ Upstream commit 6442df49 ]
      
      If ida_simple_get() returns an error when called in rproc_alloc(),
      put_device() is called to clean things up.  By this time the rproc
      device type has been assigned, with rproc_type_release() as the
      release function.
      
      The first thing rproc_type_release() does is call:
          idr_destroy(&rproc->notifyids);
      
      But at the time the ida_simple_get() call is made, the notifyids
      field in the remoteproc structure has not been initialized.
      
      I'm not actually sure this case causes an observable problem, but
      it's incorrect.  Fix this by initializing the notifyids field before
      calling ida_simple_get() in rproc_alloc().
      
      Fixes: b5ab5e24 ("remoteproc: maintain a generic child device for each rproc")
      Signed-off-by: default avatarAlex Elder <elder@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarSuman Anna <s-anna@ti.com>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Link: https://lore.kernel.org/r/20200415204858.2448-2-mathieu.poirier@linaro.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ef3b1056
    • Andy Shevchenko's avatar
      iio: pressure: bmp280: Tolerate IRQ before registering · c4f970c1
      Andy Shevchenko authored
      [ Upstream commit 97b31a6f ]
      
      With DEBUG_SHIRQ enabled we have a kernel crash
      
      [  116.482696] BUG: kernel NULL pointer dereference, address: 0000000000000000
      
      ...
      
      [  116.606571] Call Trace:
      [  116.609023]  <IRQ>
      [  116.611047]  complete+0x34/0x50
      [  116.614206]  bmp085_eoc_irq+0x9/0x10 [bmp280]
      
      because DEBUG_SHIRQ mechanism fires an IRQ before registration and drivers
      ought to be able to handle an interrupt happening before request_irq() returns.
      
      Fixes: aae95394 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4f970c1
    • Adam Honse's avatar
      i2c: piix4: Detect secondary SMBus controller on AMD AM4 chipsets · 75add7b2
      Adam Honse authored
      [ Upstream commit f27237c1 ]
      
      The AMD X370 and other AM4 chipsets (A/B/X 3/4/5 parts) and Threadripper
      equivalents have a secondary SMBus controller at I/O port address
      0x0B20.  This bus is used by several manufacturers to control
      motherboard RGB lighting via embedded controllers.  I have been using
      this bus in my OpenRGB project to control the Aura RGB on many
      motherboards and ASRock also uses this bus for their Polychrome RGB
      controller.
      
      I am not aware of any CZ-compatible platforms which do not have the
      second SMBus channel.  All of AMD's AM4- and Threadripper- series
      chipsets that OpenRGB users have tested appear to have this secondary
      bus.  I also noticed this secondary bus is present on older AMD
      platforms including my FM1 home server.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202587Signed-off-by: default avatarAdam Honse <calcprogrammer1@gmail.com>
      Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
      Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Tested-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      75add7b2