Skip to content

Commit dff10bb

Browse files
sunke-lpaxboe
authored andcommitted
nbd:fix memory leak in nbd_get_socket()
Before returning NULL, put the sock first. Cc: stable@vger.kernel.org Fixes: cf1b232 ("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>
1 parent dcb77e4 commit dff10bb

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎drivers/block/nbd.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
993993
if (sock->ops->shutdown == sock_no_shutdown) {
994994
dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n");
995995
*err = -EINVAL;
996+
sockfd_put(sock);
996997
return NULL;
997998
}
998999

0 commit comments

Comments
 (0)