public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix reference counting for failed SCSI devices
@ 2005-05-24  9:38 Hannes Reinecke
  2005-05-24 22:57 ` James Bottomley
  0 siblings, 1 reply; 9+ messages in thread
From: Hannes Reinecke @ 2005-05-24  9:38 UTC (permalink / raw)
  To: James Bottomley; +Cc: SCSI Mailing List, Linux Kernel

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

Hi James,

whenever the scsi-ml tries to scan non-existent devices the reference
count in scsi_alloc_sdev() and scsi_probe_and_add_lun() is not adjusted
properly. Every call to XXX_initialize in the driver core sets the
reference count to 1, so for a proper deallocation an explicit XXX_put()
has to be done.

Please apply.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			hare@suse.de
SuSE Linux AG				S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[-- Attachment #2: linux-2.6.12-rc4-scsi-scan-fix-refcount-on-fail --]
[-- Type: text/plain, Size: 1279 bytes --]

From: Hannes Reinecke <hare@suse.de>
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
@@ -273,6 +273,7 @@ static struct scsi_device *scsi_alloc_sd
 			 */
 			if (ret == -ENXIO)
 				display_failure_msg = 0;
+			put_device(&starget->dev);
 			goto out_device_destroy;
 		}
 	}
@@ -282,6 +283,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 +857,8 @@ 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.parent);
 		put_device(&sdev->sdev_gendev);
 	}
  out:

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-05-25 18:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-24  9:38 [PATCH] Fix reference counting for failed SCSI devices Hannes Reinecke
2005-05-24 22:57 ` James Bottomley
2005-05-25  6:50   ` Hannes Reinecke
2005-05-25 12:27     ` James Bottomley
2005-05-25 12:46       ` Hannes Reinecke
2005-05-25 14:58         ` James Bottomley
2005-05-25 15:16           ` Hannes Reinecke
2005-05-25 17:51             ` James Bottomley
2005-05-25 18:01               ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox