mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-28 07:13:34 +00:00
[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 <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
parent
4c2133c823
commit
f80f868ec4
1 changed files with 8 additions and 1 deletions
|
@ -219,6 +219,7 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint);
|
||||||
|
|
||||||
struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
|
struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
|
||||||
{
|
{
|
||||||
|
struct iscsi_endpoint *ep;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
dev = class_find_device(&iscsi_endpoint_class, &handle,
|
dev = class_find_device(&iscsi_endpoint_class, &handle,
|
||||||
|
@ -226,7 +227,13 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return NULL;
|
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);
|
EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue