]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
nbd: stop leaking sockets
authorJosef Bacik <jbacik@fb.com>
Wed, 1 Mar 2017 16:47:22 +0000 (11:47 -0500)
committerJens Axboe <axboe@fb.com>
Thu, 2 Mar 2017 15:56:04 +0000 (08:56 -0700)
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>
drivers/block/nbd.c

index 0bf2b21a62cb770a3129889b59a0b5f735eddc52..c7e93f62366fb109a138262261f150efc66b2b97 100644 (file)
@@ -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;