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: [email protected] Fixes: cf1b232 ("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]>
1 parent dcb77e4 commit dff10bb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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)