From: Mike Christie Date: Mon, 16 Jun 2008 15:11:35 +0000 (-0500) Subject: [SCSI] iscsi class: fix endpoint leak X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=f80f868ec463b0463b332cdb704fe5438f013f98;p=openwrt%2Fstaging%2Fblogic.git [SCSI] iscsi class: fix endpoint leak 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 Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 8e34f3c08575..3af7cbcc5c5d 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -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);