diff mbox

iscsi: Fix iscsi endpoints leak

Message ID 1432114738-967-1-git-send-email-sagig@mellanox.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sagi Grimberg May 20, 2015, 9:38 a.m. UTC
When creating a new endpoint, we look for a free id
for the new endpoint. We baisically loop on possible ids
and use the first id that class_find_device() returns NULL.
However, we are missing a reference put when class_find_device()
does find an existing device for a given id.

Reported-by: Alex Lyakas <alex@zadarastorage.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
---
 drivers/scsi/scsi_transport_iscsi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Sagi Grimberg June 2, 2015, 3:21 p.m. UTC | #1
On 5/20/2015 12:38 PM, Sagi Grimberg wrote:
> When creating a new endpoint, we look for a free id
> for the new endpoint. We baisically loop on possible ids
> and use the first id that class_find_device() returns NULL.
> However, we are missing a reference put when class_find_device()
> does find an existing device for a given id.
>
> Reported-by: Alex Lyakas <alex@zadarastorage.com>
> Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
> ---
>   drivers/scsi/scsi_transport_iscsi.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
> index 67d43e3..55647aa 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -204,6 +204,8 @@ iscsi_create_endpoint(int dd_size)
>   					iscsi_match_epid);
>   		if (!dev)
>   			break;
> +		else
> +			put_device(dev);
>   	}
>   	if (id == ISCSI_MAX_EPID) {
>   		printk(KERN_ERR "Too many connections. Max supported %u\n",
>

ping?

Mike, can I get a review on this one?

I think this leak existed since this code was introduced
in 2.6.37, but I've only tested back to 3.10.

So I think this deserves a CC to stable 3.10+
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mike Christie June 2, 2015, 5:23 p.m. UTC | #2
On 05/20/2015 04:38 AM, Sagi Grimberg wrote:
> When creating a new endpoint, we look for a free id
> for the new endpoint. We baisically loop on possible ids
> and use the first id that class_find_device() returns NULL.
> However, we are missing a reference put when class_find_device()
> does find an existing device for a given id.
> 
> Reported-by: Alex Lyakas <alex@zadarastorage.com>
> Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
> ---
>  drivers/scsi/scsi_transport_iscsi.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
> index 67d43e3..55647aa 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -204,6 +204,8 @@ iscsi_create_endpoint(int dd_size)
>  					iscsi_match_epid);
>  		if (!dev)
>  			break;
> +		else
> +			put_device(dev);
>  	}
>  	if (id == ISCSI_MAX_EPID) {
>  		printk(KERN_ERR "Too many connections. Max supported %u\n",
> 

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 67d43e3..55647aa 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -204,6 +204,8 @@  iscsi_create_endpoint(int dd_size)
 					iscsi_match_epid);
 		if (!dev)
 			break;
+		else
+			put_device(dev);
 	}
 	if (id == ISCSI_MAX_EPID) {
 		printk(KERN_ERR "Too many connections. Max supported %u\n",