linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v2] nbd:fix memory leak in nbd_get_socket()
@ 2019-11-19  6:09 Sun Ke
  2019-11-19 16:13 ` Jens Axboe
  2019-11-19 16:22 ` Mike Christie
  0 siblings, 2 replies; 5+ messages in thread
From: Sun Ke @ 2019-11-19  6:09 UTC (permalink / raw)
  To: sunke32, josef, axboe, linux-block, nbd, linux-kernel; +Cc: stable

Before return NULL,put the sock first.

Cc: stable@vger.kernel.org
Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup")
Signed-off-by: Sun Ke <sunke32@huawei.com>
---
v2: add cc:stable tag
---
 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a94ee45..19e7599 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -993,6 +993,7 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
 	if (sock->ops->shutdown == sock_no_shutdown) {
 		dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n");
 		*err = -EINVAL;
+		sockfd_put(sock);
 		return NULL;
 	}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [v2] nbd:fix memory leak in nbd_get_socket()
  2019-11-19  6:09 [v2] nbd:fix memory leak in nbd_get_socket() Sun Ke
@ 2019-11-19 16:13 ` Jens Axboe
  2019-11-19 16:16   ` Josef Bacik
  2019-11-19 16:22 ` Mike Christie
  1 sibling, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2019-11-19 16:13 UTC (permalink / raw)
  To: Sun Ke, josef, linux-block, nbd, linux-kernel; +Cc: Mike Christie

On 11/18/19 11:09 PM, Sun Ke wrote:
> Before return NULL,put the sock first.
> 
> Cc: stable@vger.kernel.org
> Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup")
> Signed-off-by: Sun Ke <sunke32@huawei.com>

Please always CC the author of the patch you're fixing.

Mike, Josef - we probably need to get this upstream ASAP.

> ---
> v2: add cc:stable tag
> ---
>   drivers/block/nbd.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index a94ee45..19e7599 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -993,6 +993,7 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
>   	if (sock->ops->shutdown == sock_no_shutdown) {
>   		dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n");
>   		*err = -EINVAL;
> +		sockfd_put(sock);
>   		return NULL;
>   	}
>   
> 


-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v2] nbd:fix memory leak in nbd_get_socket()
  2019-11-19 16:13 ` Jens Axboe
@ 2019-11-19 16:16   ` Josef Bacik
  0 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2019-11-19 16:16 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Sun Ke, josef, linux-block, nbd, linux-kernel, Mike Christie

On Tue, Nov 19, 2019 at 09:13:34AM -0700, Jens Axboe wrote:
> On 11/18/19 11:09 PM, Sun Ke wrote:
> > Before return NULL,put the sock first.
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup")
> > Signed-off-by: Sun Ke <sunke32@huawei.com>
> 
> Please always CC the author of the patch you're fixing.
> 
> Mike, Josef - we probably need to get this upstream ASAP.

Yup sorry got distracted,

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v2] nbd:fix memory leak in nbd_get_socket()
  2019-11-19  6:09 [v2] nbd:fix memory leak in nbd_get_socket() Sun Ke
  2019-11-19 16:13 ` Jens Axboe
@ 2019-11-19 16:22 ` Mike Christie
  2019-11-19 16:23   ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Mike Christie @ 2019-11-19 16:22 UTC (permalink / raw)
  To: Sun Ke, josef, axboe, linux-block, nbd, linux-kernel; +Cc: stable

On 11/19/2019 12:09 AM, Sun Ke wrote:
> Before return NULL,put the sock first.
> 
> Cc: stable@vger.kernel.org
> Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup")
> Signed-off-by: Sun Ke <sunke32@huawei.com>
> ---
> v2: add cc:stable tag
> ---
>  drivers/block/nbd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index a94ee45..19e7599 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -993,6 +993,7 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
>  	if (sock->ops->shutdown == sock_no_shutdown) {
>  		dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n");
>  		*err = -EINVAL;
> +		sockfd_put(sock);
>  		return NULL;
>  	}
>  
> 

Reviewed-by: Mike Christie <mchristi@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v2] nbd:fix memory leak in nbd_get_socket()
  2019-11-19 16:22 ` Mike Christie
@ 2019-11-19 16:23   ` Jens Axboe
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2019-11-19 16:23 UTC (permalink / raw)
  To: Mike Christie, Sun Ke, josef, linux-block, nbd, linux-kernel; +Cc: stable

On 11/19/19 9:22 AM, Mike Christie wrote:
> On 11/19/2019 12:09 AM, Sun Ke wrote:
>> Before return NULL,put the sock first.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup")
>> Signed-off-by: Sun Ke <sunke32@huawei.com>
>> ---
>> v2: add cc:stable tag
>> ---
>>   drivers/block/nbd.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
>> index a94ee45..19e7599 100644
>> --- a/drivers/block/nbd.c
>> +++ b/drivers/block/nbd.c
>> @@ -993,6 +993,7 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
>>   	if (sock->ops->shutdown == sock_no_shutdown) {
>>   		dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n");
>>   		*err = -EINVAL;
>> +		sockfd_put(sock);
>>   		return NULL;
>>   	}
>>   
>>
> 
> Reviewed-by: Mike Christie <mchristi@redhat.com>

Thanks (both of you), applied for 5.4.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-19 16:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19  6:09 [v2] nbd:fix memory leak in nbd_get_socket() Sun Ke
2019-11-19 16:13 ` Jens Axboe
2019-11-19 16:16   ` Josef Bacik
2019-11-19 16:22 ` Mike Christie
2019-11-19 16:23   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).