提交 4ade5e13 编写于 作者: C Colin Ian King 提交者: Xie XiuQi

block/rnbd: fix a null pointer dereference on dev->blk_symlink_name

stable inclusion
from stable-5.10.4
commit aa4f552aec3d43cc1455490825399d178da0a65f
bugzilla: 46903

--------------------------------

[ Upstream commit 733c15bd ]

Currently in the case where dev->blk_symlink_name fails to be allocates
the error return path attempts to set an end-of-string character to
the unallocated dev->blk_symlink_name causing a null pointer dereference
error. Fix this by returning with an explicity ENOMEM error (which also
is missing in the original code as was not initialized).

Fixes: 1eb54f8f ("block/rnbd: client: sysfs interface functions")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Addresses-Coverity: ("Dereference after null check")
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 52ec397c
......@@ -494,7 +494,7 @@ static int rnbd_clt_add_dev_symlink(struct rnbd_clt_dev *dev)
dev->blk_symlink_name = kzalloc(len, GFP_KERNEL);
if (!dev->blk_symlink_name) {
rnbd_clt_err(dev, "Failed to allocate memory for blk_symlink_name\n");
goto out_err;
return -ENOMEM;
}
ret = rnbd_clt_get_path_name(dev, dev->blk_symlink_name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部