]> 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)
commit436f93b69e6c0c7f6f8e2cc293415beb10113a10
tree03f155748825eba1c7afbdc19aa714e8cce8c540
parent77431c9eeeb4884bf85c3b2cfc7350a350d6cf37
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: f565cf1abbcf ("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