提交 312b0efe 编写于 作者: Y YueHaibing 提交者: sanglipeng

net/mlx5: Fix uninitialized variable bug in outlen_write()

stable inclusion
from stable-v5.10.158
commit 2cb84ff34938cc3cdfe2d90e70cf8a8ced66fd1e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2cb84ff34938cc3cdfe2d90e70cf8a8ced66fd1e

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

[ Upstream commit 3f5769a0 ]

If sscanf() return 0, outlen is uninitialized and used in kzalloc(),
this is unexpected. We should return -EINVAL if the string is invalid.

Fixes: e126ba97 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: NSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 f9f41643
......@@ -1422,8 +1422,8 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
return -EFAULT;
err = sscanf(outlen_str, "%d", &outlen);
if (err < 0)
return err;
if (err != 1)
return -EINVAL;
ptr = kzalloc(outlen, GFP_KERNEL);
if (!ptr)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册