Commit fbce4d97 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

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: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarKyle Fortin <kyle.fortin@oracle.com>
Tested-by: default avatarDon Brace <don.brace@microsemi.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 88e65389
...@@ -1376,13 +1376,19 @@ static void __scsi_remove_target(struct scsi_target *starget) ...@@ -1376,13 +1376,19 @@ static void __scsi_remove_target(struct scsi_target *starget)
spin_lock_irqsave(shost->host_lock, flags); spin_lock_irqsave(shost->host_lock, flags);
restart: restart:
list_for_each_entry(sdev, &shost->__devices, siblings) { list_for_each_entry(sdev, &shost->__devices, siblings) {
/*
* We cannot call scsi_device_get() here, as
* we might've been called from rmmod() causing
* scsi_device_get() to fail the module_is_live()
* check.
*/
if (sdev->channel != starget->channel || if (sdev->channel != starget->channel ||
sdev->id != starget->id || sdev->id != starget->id ||
scsi_device_get(sdev)) !get_device(&sdev->sdev_gendev))
continue; continue;
spin_unlock_irqrestore(shost->host_lock, flags); spin_unlock_irqrestore(shost->host_lock, flags);
scsi_remove_device(sdev); scsi_remove_device(sdev);
scsi_device_put(sdev); put_device(&sdev->sdev_gendev);
spin_lock_irqsave(shost->host_lock, flags); spin_lock_irqsave(shost->host_lock, flags);
goto restart; goto restart;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment