1. 22 11月, 2019 3 次提交
    • J
      scsi: scsi_transport_sas: Fix memory leak when removing devices · 82ea3e0e
      John Garry 提交于
      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.comSigned-off-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      82ea3e0e
    • J
      scsi: lpfc: size cpu map by last cpu id set · eede4970
      James Smart 提交于
      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.comSigned-off-by: NDick Kennedy <dick.kennedy@broadcom.com>
      Signed-off-by: NJames Smart <jsmart2021@gmail.com>
      Reviewed-by: NEwan D. Milne <emilne@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      eede4970
    • S
      scsi: ibmvscsi_tgt: Remove unneeded variable rc · 75d886a9
      Saurav Girepunje 提交于
      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@sauravSigned-off-by: NSaurav Girepunje <saurav.girepunje@gmail.com>
      Reviewed-by: NTyrel Datwyler <tyreld@linux.ibm.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      75d886a9
  2. 20 11月, 2019 31 次提交
  3. 19 11月, 2019 4 次提交
  4. 13 11月, 2019 2 次提交
    • F
      scsi: core: Clean up SG_NONE · 35c33633
      Finn Thain 提交于
      Remove SG_NONE and a related misleading comment. Update documentation.
      
      This patch does not affect behaviour as zero initialization is redundant.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Viresh Kumar <vireshk@kernel.org>
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: usb-storage@lists.one-eyed-alien.net
      Link: https://lore.kernel.org/r/b4779b7a6563f6bd8d259ee457871c1c463c420e.1572656814.git.fthain@telegraphics.com.auSigned-off-by: NFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      35c33633
    • F
      scsi: atari_scsi: sun3_scsi: Set sg_tablesize to 1 instead of SG_NONE · 79172ab2
      Finn Thain 提交于
      Since the scsi subsystem adopted the blk-mq API, a host with zero
      sg_tablesize crashes with a NULL pointer dereference.
      
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:0:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
      scsi target0:0:0: Beginning Domain Validation
      scsi target0:0:0: Domain Validation skipping write tests
      scsi target0:0:0: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:1:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
      scsi target0:0:1: Beginning Domain Validation
      scsi target0:0:1: Domain Validation skipping write tests
      scsi target0:0:1: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
      scsi target0:0:2: Beginning Domain Validation
      scsi target0:0:2: Domain Validation skipping write tests
      scsi target0:0:2: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      sr 0:0:2:0: Power-on or device reset occurred
      sd 0:0:0:0: Power-on or device reset occurred
      sd 0:0:1:0: Power-on or device reset occurred
      sd 0:0:0:0: [sda] 10485762 512-byte logical blocks: (5.37 GB/5.00 GiB)
      sd 0:0:0:0: [sda] Write Protect is off
      sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
      Unable to handle kernel NULL pointer dereference at virtual address (ptrval)
      Oops: 00000000
      Modules linked in:
      PC: [<001cd874>] blk_mq_free_request+0x66/0xe2
      SR: 2004  SP: (ptrval)  a2: 00874520
      d0: 00000000    d1: 00000000    d2: 009ba800    d3: 00000000
      d4: 00000000    d5: 08000002    a0: 0087be68    a1: 009a81e0
      Process kworker/u2:2 (pid: 15, task=(ptrval))
      Frame format=7 eff addr=0000007a ssw=0505 faddr=0000007a
      wb 1 stat/addr/data: 0000 00000000 00000000
      wb 2 stat/addr/data: 0000 00000000 00000000
      wb 3 stat/addr/data: 0000 0000007a 00000000
      push data: 00000000 00000000 00000000 00000000
      Stack from 0087bd98:
              00000002 00000000 0087be72 009a7820 0087bdb4 001c4f6c 009a7820 0087bdd4
              0024d200 009a7820 0024d0dc 0087be72 009baa00 0087be68 009a5000 0087be7c
              00265d10 009a5000 0087be72 00000003 00000000 00000000 00000000 0087be68
              00000bb8 00000005 00000000 00000000 00000000 00000000 00265c56 00000000
              009ba60c 0036ddf4 00000002 ffffffff 009baa00 009ba600 009a50d6 0087be74
              00227ba0 009baa08 00000001 009baa08 009ba60c 0036ddf4 00000000 00000000
      Call Trace: [<001c4f6c>] blk_put_request+0xe/0x14
       [<0024d200>] __scsi_execute+0x124/0x174
       [<0024d0dc>] __scsi_execute+0x0/0x174
       [<00265d10>] sd_revalidate_disk+0xba/0x1f02
       [<00265c56>] sd_revalidate_disk+0x0/0x1f02
       [<0036ddf4>] strlen+0x0/0x22
       [<00227ba0>] device_add+0x3da/0x604
       [<0036ddf4>] strlen+0x0/0x22
       [<00267e64>] sd_probe+0x30c/0x4b4
       [<0002da44>] process_one_work+0x0/0x402
       [<0022b978>] really_probe+0x226/0x354
       [<0022bc34>] driver_probe_device+0xa4/0xf0
       [<0002da44>] process_one_work+0x0/0x402
       [<0022bcd0>] __driver_attach_async_helper+0x50/0x70
       [<00035dae>] async_run_entry_fn+0x36/0x130
       [<0002db88>] process_one_work+0x144/0x402
       [<0002e1aa>] worker_thread+0x0/0x570
       [<0002e29a>] worker_thread+0xf0/0x570
       [<0002e1aa>] worker_thread+0x0/0x570
       [<003768d8>] schedule+0x0/0xb8
       [<0003f58c>] __init_waitqueue_head+0x0/0x12
       [<00033e92>] kthread+0xc2/0xf6
       [<000331e8>] kthread_parkme+0x0/0x4e
       [<003768d8>] schedule+0x0/0xb8
       [<00033dd0>] kthread+0x0/0xf6
       [<00002c10>] ret_from_kernel_thread+0xc/0x14
      Code: 0280 0006 0800 56c0 4400 0280 0000 00ff <52b4> 0c3a 082b 0006 0013 6706 2042 53a8 00c4 4ab9 0047 3374 6640 202d 000c 670c
      Disabling lock debugging due to kernel taint
      
      Avoid this by setting sg_tablesize = 1.
      
      Link: https://lore.kernel.org/r/4567bcae94523b47d6f3b77450ba305823bca479.1572656814.git.fthain@telegraphics.com.auReported-and-tested-by: NMichael Schmitz <schmitzmic@gmail.com>
      Reviewed-by: NMichael Schmitz <schmitzmic@gmail.com>
      References: commit 68ab2d76 ("scsi: cxlflash: Set sg_tablesize to 1 instead of SG_NONE")
      Signed-off-by: NFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      79172ab2