Skip to content

Commit

Permalink
nbd: stop leaking sockets
Browse files Browse the repository at this point in the history
This was introduced in the multi-connection patch, we've been leaking
socket's ever since.

Fixes: 9561a7a ("nbd: add multi-connection support")
cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Josef Bacik authored and Jens Axboe committed Mar 2, 2017
1 parent 562bef4 commit 6a8a215
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,10 @@ static int nbd_clear_sock(struct nbd_device *nbd, struct block_device *bdev)
nbd->num_connections) {
int i;

for (i = 0; i < nbd->num_connections; i++)
for (i = 0; i < nbd->num_connections; i++) {
sockfd_put(nbd->socks[i]->sock);
kfree(nbd->socks[i]);
}
kfree(nbd->socks);
nbd->socks = NULL;
nbd->num_connections = 0;
Expand Down

0 comments on commit 6a8a215

Please sign in to comment.