Commit b162526c authored by Zheng Bin's avatar Zheng Bin Committed by Yang Yingliang
Browse files

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: default avatar <syzbot+934037347002901b8d2a@syzkaller.appspotmail.com>
Signed-off-by: default avatarZheng Bin <zhengbin13@huawei.com>
Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 6f4d0434
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment