From: Hannes Reinecke Subject: Fix refcount for failed devices When a non-present device is scanned it is not properly deregistered from the driver core. Calling XXX_initialize() functions from the driver core sets the reference count to 1, so for proper deallocation a XXX_put() has to be issued. --- linux-2.6.12-rc4/drivers/scsi/scsi_scan.c.orig 2005-05-24 10:26:46.000000000 +0200 +++ linux-2.6.12-rc4/drivers/scsi/scsi_scan.c 2005-05-24 10:55:52.000000000 +0200 @@ -282,6 +282,7 @@ static struct scsi_device *scsi_alloc_sd out_device_destroy: transport_destroy_device(&sdev->sdev_gendev); scsi_free_queue(sdev->request_queue); + class_device_put(&sdev->sdev_classdev); put_device(&sdev->sdev_gendev); out: if (display_failure_msg) @@ -855,6 +856,7 @@ static int scsi_probe_and_add_lun(struct if (sdev->host->hostt->slave_destroy) sdev->host->hostt->slave_destroy(sdev); transport_destroy_device(&sdev->sdev_gendev); + class_device_put(&sdev->sdev_classdev); put_device(&sdev->sdev_gendev); } out: