Commit 40f816ba authored by Brian King's avatar Brian King Committed by Christoph Hellwig

[PATCH] fix scsi_remove_device locking

The following patch fixes an oops I was seeing on a machine with
misconfigured scsi cables, but could feasibly happen in other paths.
The oops was occurring because scsi_remove_device was getting
called for a device before scsi_add_device had fully completed.
This resulted in sysfs_remove_link being called with a NULL dentry.
Signed-off-by: default avatarBrian King <brking@us.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 93544c1a
...@@ -525,8 +525,11 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -525,8 +525,11 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
**/ **/
void scsi_remove_device(struct scsi_device *sdev) void scsi_remove_device(struct scsi_device *sdev)
{ {
struct Scsi_Host *shost = sdev->host;
down(&shost->scan_mutex);
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
return; goto out;
class_device_unregister(&sdev->sdev_classdev); class_device_unregister(&sdev->sdev_classdev);
if (sdev->transport_classdev.class) if (sdev->transport_classdev.class)
...@@ -538,6 +541,9 @@ void scsi_remove_device(struct scsi_device *sdev) ...@@ -538,6 +541,9 @@ void scsi_remove_device(struct scsi_device *sdev)
if (sdev->host->transportt->cleanup) if (sdev->host->transportt->cleanup)
sdev->host->transportt->cleanup(sdev); sdev->host->transportt->cleanup(sdev);
put_device(&sdev->sdev_gendev); put_device(&sdev->sdev_gendev);
out:
up(&shost->scan_mutex);
} }
int scsi_register_driver(struct device_driver *drv) int scsi_register_driver(struct device_driver *drv)
......
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