[SCSI] iscsi class: fix endpoint leak
authorMike Christie <michaelc@cs.wisc.edu>
Mon, 16 Jun 2008 15:11:35 +0000 (10:11 -0500)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Sat, 12 Jul 2008 13:22:30 +0000 (08:22 -0500)
class_find_device gets a ref to the device so we must release it.
The class will serialize access to the ep so we do not have to worry
about a remove racing with the callers access, so we can simplify the
use and drop the ref right away.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/scsi_transport_iscsi.c

index 8e34f3c085754ee244f7fc80186f9303d1230a3a..3af7cbcc5c5d7c6f93822a2e7e29f15f17a7df13 100644 (file)
@@ -219,6 +219,7 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint);
 
 struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
 {
+       struct iscsi_endpoint *ep;
        struct device *dev;
 
        dev = class_find_device(&iscsi_endpoint_class, &handle,
@@ -226,7 +227,13 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
        if (!dev)
                return NULL;
 
-       return iscsi_dev_to_endpoint(dev);
+       ep = iscsi_dev_to_endpoint(dev);
+       /*
+        * we can drop this now because the interface will prevent
+        * removals and lookups from racing.
+        */
+       put_device(dev);
+       return ep;
 }
 EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint);
 
This page took 0.044944 seconds and 5 git commands to generate.