Skip to content

Commit 875758d

Browse files
hreineckegregkh
authored andcommitted
scsi: core: check for device state in __scsi_remove_target()
commit 81b6c99 upstream. As it turned out device_get() doesn't use kref_get_unless_zero(), so we will be always getting a device pointer. Consequently, we need to check for the device state in __scsi_remove_target() to avoid tripping over deleted objects. Fixes: fbce4d9 ("scsi: fixup kernel warning during rmmod()") Reported-by: Jason Yan <yanaijie@huawei.com> Signed-off-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Cc: Max Ivanov <ivanov.maxim@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 26f8c38 commit 875758d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎drivers/scsi/scsi_sysfs.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,10 @@ static void __scsi_remove_target(struct scsi_target *starget)
13831383
* check.
13841384
*/
13851385
if (sdev->channel != starget->channel ||
1386-
sdev->id != starget->id ||
1386+
sdev->id != starget->id)
1387+
continue;
1388+
if (sdev->sdev_state == SDEV_DEL ||
1389+
sdev->sdev_state == SDEV_CANCEL ||
13871390
!get_device(&sdev->sdev_gendev))
13881391
continue;
13891392
spin_unlock_irqrestore(shost->host_lock, flags);

0 commit comments

Comments
 (0)