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: Brian King --- linux-2.6.7-bjking1/drivers/scsi/scsi_sysfs.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletion(-) diff -puN drivers/scsi/scsi_sysfs.c~scsi_remove_device_locking drivers/scsi/scsi_sysfs.c --- linux-2.6.7/drivers/scsi/scsi_sysfs.c~scsi_remove_device_locking 2004-07-02 11:34:25.000000000 -0500 +++ linux-2.6.7-bjking1/drivers/scsi/scsi_sysfs.c 2004-07-02 15:29:59.000000000 -0500 @@ -524,8 +524,11 @@ int scsi_sysfs_add_sdev(struct scsi_devi **/ 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) - return; + goto out; class_device_unregister(&sdev->sdev_classdev); if (sdev->transport_classdev.class) @@ -537,6 +540,9 @@ void scsi_remove_device(struct scsi_devi if (sdev->host->transportt->cleanup) sdev->host->transportt->cleanup(sdev); put_device(&sdev->sdev_gendev); + +out: + up(&shost->scan_mutex); } int scsi_register_driver(struct device_driver *drv) _