]> git.baikalelectronics.ru Git - kernel.git/commit
nbd: Fix memory leak in nbd_add_socket
authorZheng Bin <zhengbin13@huawei.com>
Mon, 29 Jun 2020 01:23:49 +0000 (09:23 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 8 Jul 2020 21:42:18 +0000 (15:42 -0600)
commitfbac4a7bd1d270960c6bc3c95a397e6331896a3c
tree03f155748825eba1c7afbdc19aa714e8cce8c540
parent43843704478a185c3230f921fc07894d37e92d91
nbd: Fix memory leak in nbd_add_socket

When adding first socket to nbd, if nsock's allocation failed, the data
structure member "config->socks" was reallocated, but the data structure
member "config->num_connections" was not updated. A memory leak will occur
then because the function "nbd_config_put" will free "config->socks" only
when "config->num_connections" is not zero.

Fixes: 4aee21cb2c72 ("nbd: prevent memory leak")
Reported-by: syzbot+934037347002901b8d2a@syzkaller.appspotmail.com
Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c