diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2008-06-16 11:11:35 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-07-12 09:22:30 -0400 |
commit | f80f868ec463b0463b332cdb704fe5438f013f98 (patch) | |
tree | 5280f9c355ad08d659bacaaae41da697ddbd7345 /drivers/scsi/scsi_transport_iscsi.c | |
parent | 4c2133c82385c31dd3eed76b07da1e986eb00294 (diff) |
[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>
Diffstat (limited to 'drivers/scsi/scsi_transport_iscsi.c')
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); | |||
219 | 219 | ||
220 | struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) | 220 | struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) |
221 | { | 221 | { |
222 | struct iscsi_endpoint *ep; | ||
222 | struct device *dev; | 223 | struct device *dev; |
223 | 224 | ||
224 | dev = class_find_device(&iscsi_endpoint_class, &handle, | 225 | dev = class_find_device(&iscsi_endpoint_class, &handle, |
@@ -226,7 +227,13 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) | |||
226 | if (!dev) | 227 | if (!dev) |
227 | return NULL; | 228 | return NULL; |
228 | 229 | ||
229 | return iscsi_dev_to_endpoint(dev); | 230 | ep = iscsi_dev_to_endpoint(dev); |
231 | /* | ||
232 | * we can drop this now because the interface will prevent | ||
233 | * removals and lookups from racing. | ||
234 | */ | ||
235 | put_device(dev); | ||
236 | return ep; | ||
230 | } | 237 | } |
231 | EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); | 238 | EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); |
232 | 239 | ||