diff options
author | Sun Ke <sunke32@huawei.com> | 2019-11-19 14:09:11 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-01 09:16:09 +0100 |
commit | 65d153c8ed6505075740f005122d01298f6e474a (patch) | |
tree | 3fc645ea0c467323ff48c26c28dee0d6f0516cf1 /drivers/block | |
parent | 036588ec6888ad085c9a2edc5c0bac12297f5e35 (diff) | |
download | linux-stable-65d153c8ed6505075740f005122d01298f6e474a.tar.gz linux-stable-65d153c8ed6505075740f005122d01298f6e474a.tar.bz2 linux-stable-65d153c8ed6505075740f005122d01298f6e474a.zip |
nbd:fix memory leak in nbd_get_socket()
commit dff10bbea4be47bdb615b036c834a275b7c68133 upstream.
Before returning NULL, put the sock first.
Cc: stable@vger.kernel.org
Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup")
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Sun Ke <sunke32@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nbd.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 867841c56a6d..d76840873420 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -945,6 +945,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; } |