Skip to content

Commit fbce4d9

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: fixup kernel warning during rmmod()
Calling rmmod() on a FC driver will results in warnings like WARNING: CPU: 60 PID: 14640 at fs/sysfs/group.c:237 device_del+0x54/0x240() sysfs group ffffffff81eff140 not found for kobject '3:0:0:3' The problem here is that during scsi_remove_target() we will iterate over all devices, but fail to remove any of those as the call to scsi_device_get() fails the check to module_is_live(). Hence the devices will not be removed at this point, but all intermediate structures like fc rport etc. will be. Later on during scsi_forget_host() the devices are removed for real, but the device parent is already removed and causes this warning. Signed-off-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com> Tested-by: Don Brace <don.brace@microsemi.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 88e6538 commit fbce4d9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎drivers/scsi/scsi_sysfs.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,13 +1376,19 @@ static void __scsi_remove_target(struct scsi_target *starget)
13761376
spin_lock_irqsave(shost->host_lock, flags);
13771377
restart:
13781378
list_for_each_entry(sdev, &shost->__devices, siblings) {
1379+
/*
1380+
* We cannot call scsi_device_get() here, as
1381+
* we might've been called from rmmod() causing
1382+
* scsi_device_get() to fail the module_is_live()
1383+
* check.
1384+
*/
13791385
if (sdev->channel != starget->channel ||
13801386
sdev->id != starget->id ||
1381-
scsi_device_get(sdev))
1387+
!get_device(&sdev->sdev_gendev))
13821388
continue;
13831389
spin_unlock_irqrestore(shost->host_lock, flags);
13841390
scsi_remove_device(sdev);
1385-
scsi_device_put(sdev);
1391+
put_device(&sdev->sdev_gendev);
13861392
spin_lock_irqsave(shost->host_lock, flags);
13871393
goto restart;
13881394
}

0 commit comments

Comments
 (0)