Skip to content
  1. Nov 27, 2019
  2. Nov 22, 2019
    • John Garry's avatar
      scsi: scsi_transport_sas: Fix memory leak when removing devices · 82ea3e0e
      John Garry authored
      Removing a non-host rphy causes a memory leak:
      
      root@(none)$ echo 0 > /sys/devices/platform/HISI0162:01/host0/port-0:0/expander-0:0/port-0:0:10/phy-0:0:10/sas_phy/phy-0:0:10/enable
      [   79.857888] hisi_sas_v2_hw HISI0162:01: dev[7:1] is gone
      root@(none)$ echo scan > /sys/kernel/debug/kmemleak
      [  131.656603] kmemleak: 3 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
      root@(none)$ more /sys/kernel/debug/kmemleak
      unreferenced object 0xffff041da5c66000 (size 256):
        comm "kworker/u128:1", pid 549, jiffies 4294898543 (age 113.728s)
        hex dump (first 32 bytes):
          00 5e c6 a5 1d 04 ff ff 01 00 00 00 00 00 00 00  .^..............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<(____ptrval____)>] kmem_cache_alloc+0x188/0x260
          [<(____ptrval____)>] bsg_setup_queue+0x48/0x1a8
          [<(____ptrval____)>] sas_rphy_add+0x108/0x2d0
          [<(____ptrval____)>] sas_probe_devices+0x168/0x208
          [<(____ptrval____)>] sas_discover_domain+0x660/0x9c8
          [<(____ptrval____)>] process_one_work+0x3f8/0x690
          [<(____ptrval____)>] worker_thread+0x70/0x6a0
          [<(____ptrval____)>] kthread+0x1b8/0x1c0
          [<(____ptrval____)>] ret_from_fork+0x10/0x18
      unreferenced object 0xffff041d8c075400 (size 128):
        comm "kworker/u128:1", pid 549, jiffies 4294898543 (age 113.728s)
        hex dump (first 32 bytes):
          00 40 25 97 1d 00 ff ff 00 00 00 00 00 00 00 00  .@%.............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<(____ptrval____)>] __kmalloc_node+0x1a8/0x2c8
          [<(____ptrval____)>] blk_mq_realloc_tag_set_tags.part.70+0x48/0xd8
          [<(____ptrval____)>] blk_mq_alloc_tag_set+0x1dc/0x530
          [<(____ptrval____)>] bsg_setup_queue+0xe8/0x1a8
          [<(____ptrval____)>] sas_rphy_add+0x108/0x2d0
          [<(____ptrval____)>] sas_probe_devices+0x168/0x208
          [<(____ptrval____)>] sas_discover_domain+0x660/0x9c8
          [<(____ptrval____)>] process_one_work+0x3f8/0x690
          [<(____ptrval____)>] worker_thread+0x70/0x6a0
          [<(____ptrval____)>] kthread+0x1b8/0x1c0
          [<(____ptrval____)>] ret_from_fork+0x10/0x18
      unreferenced object 0xffff041da5c65e00 (size 256):
        comm "kworker/u128:1", pid 549, jiffies 4294898543 (age 113.728s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<(____ptrval____)>] __kmalloc_node+0x1a8/0x2c8
          [<(____ptrval____)>] blk_mq_alloc_tag_set+0x254/0x530
          [<(____ptrval____)>] bsg_setup_queue+0xe8/0x1a8
          [<(____ptrval____)>] sas_rphy_add+0x108/0x2d0
          [<(____ptrval____)>] sas_probe_devices+0x168/0x208
          [<(____ptrval____)>] sas_discover_domain+0x660/0x9c8
          [<(____ptrval____)>] process_one_work+0x3f8/0x690
          [<(____ptrval____)>] worker_thread+0x70/0x6a0
          [<(____ptrval____)>] kthread+0x1b8/0x1c0
          [<(____ptrval____)>] ret_from_fork+0x10/0x18
      root@(none)$
      
      It turns out that we don't clean up the request queue fully for bsg
      devices, as the blk mq tags for the request queue are not freed.
      
      Fix by doing the queue removal in one place - in sas_rphy_remove() -
      instead of unregistering the queue in sas_rphy_remove() and finally
      cleaning up the queue in calling blk_cleanup_queue() from
      sas_end_device_release() or sas_expander_release().
      
      Function bsg_remove_queue() can handle a NULL pointer q, so remove the
      precheck in sas_rphy_remove().
      
      Fixes: 651a0136 ("scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough")
      Link: https://lore.kernel.org/r/1574242755-94156-1-git-send-email-john.garry@huawei.com
      
      
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      82ea3e0e
    • James Smart's avatar
      scsi: lpfc: size cpu map by last cpu id set · eede4970
      James Smart authored
      Currently the lpfc driver sizes its cpu_map array based on
      num_possible_cpus(). However, that can be a value that is less than the
      highest cpu id bit that is set. As such, if a thread runs on a cpu with a
      larger cpu id, or for_each_possible_cpu() is used, the driver could index
      off the end of the array and return garbage or GPF.
      
      The driver maintains its own internal copy of the "num_possible" cpu value
      and sizes arrays by it.
      
      Fix by setting the driver's value to the value of the last cpu id bit set
      in the possible_mask - plus 1. Thus cpu_map will be sized to allow access
      by any cpu id possible.
      
      Link: https://lore.kernel.org/r/20191121175556.18953-1-jsmart2021@gmail.com
      
      
      Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
      Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
      Reviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      eede4970
    • Saurav Girepunje's avatar
      scsi: ibmvscsi_tgt: Remove unneeded variable rc · 75d886a9
      Saurav Girepunje authored
      Variable rc is not modified in ibmvscsis_srp_i_logout function.  So remove
      unneeded variable rc.
      
      Issue found using coccicheck tool.
      
      Link: https://lore.kernel.org/r/20191101120407.GA9369@saurav
      
      
      Signed-off-by: default avatarSaurav Girepunje <saurav.girepunje@gmail.com>
      Reviewed-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      75d886a9
  3. Nov 20, 2019