Skip to content

Commit

Permalink
[SCSI] iscsi class: fix endpoint leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Christie authored and James Bottomley committed Jul 12, 2008
1 parent 4c2133c commit f80f868
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,21 @@ 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,
iscsi_match_epid);
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);

Expand Down

0 comments on commit f80f868

Please sign in to comment.