aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSun Ke <[email protected]>2019-11-19 14:09:11 +0800
committerJens Axboe <[email protected]>2019-11-19 09:23:26 -0700
commitdff10bbea4be47bdb615b036c834a275b7c68133 (patch)
tree6b8fb7e10bc91eb1a4a828e66eaa52e3039682a4
parentdcb77e4b274b8f13ac6482dfb09160cd2fae9a40 (diff)
nbd:fix memory leak in nbd_get_socket()
Before returning NULL, put the sock first. Cc: [email protected] Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup") Reviewed-by: Josef Bacik <[email protected]> Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Sun Ke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r--drivers/block/nbd.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a94ee45440b3..19e75999bb15 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;
}