nbd: Fix memory leak in nbd_add_socket
stable inclusion from linux-4.19.133 commit 306290bad932950adccfbf99c27b70c105c2c183 -------------------------------- [ Upstream commit 579dd91a ] 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: 03bf73c3 ("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> Signed-off-by:
Sasha Levin <sashal@kernel.org> Signed-off-by:
Yang Yingliang <yangyingliang@huawei.com>
Loading
Please sign in to comment