public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Sun Ke <sunke32@huawei.com>,
	josef@toxicpanda.com, linux-block@vger.kernel.org,
	nbd@other.debian.org, linux-kernel@vger.kernel.org
Cc: Mike Christie <mchristi@redhat.com>
Subject: Re: [v2] nbd:fix memory leak in nbd_get_socket()
Date: Tue, 19 Nov 2019 09:13:34 -0700	[thread overview]
Message-ID: <d68d17be-0c4e-1286-4327-0e3ba6600eca@kernel.dk> (raw)
In-Reply-To: <1574143751-138680-1-git-send-email-sunke32@huawei.com>

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


  reply	other threads:[~2019-11-19 16:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19  6:09 [v2] nbd:fix memory leak in nbd_get_socket() Sun Ke
2019-11-19 16:13 ` Jens Axboe [this message]
2019-11-19 16:16   ` Josef Bacik
2019-11-19 16:22 ` Mike Christie
2019-11-19 16:23   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d68d17be-0c4e-1286-4327-0e3ba6600eca@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchristi@redhat.com \
    --cc=nbd@other.debian.org \
    --cc=sunke32@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox