Skip to content

Commit 4c2319a

Browse files
author
Mohammad Kabat
committed
net/mlx5: Fix uninitialized variable bug in outlen_write()
Bugzilla: https://bugzilla.redhat.com/2112947 Upstream-status: v6.1-rc8 commit 3f5769a Author: YueHaibing <yuehaibing@huawei.com> Date: Mon Nov 21 19:22:04 2022 +0800 net/mlx5: Fix uninitialized variable bug in outlen_write() If sscanf() return 0, outlen is uninitialized and used in kzalloc(), this is unexpected. We should return -EINVAL if the string is invalid. Fixes: e126ba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Mohammad Kabat <mkabat@redhat.com>
1 parent c46d6d3 commit 4c2319a

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+2
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,8 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
14971497
return -EFAULT;
14981498

14991499
err = sscanf(outlen_str, "%d", &outlen);
1500-
if (err < 0)
1501-
return err;
1500+
if (err != 1)
1501+
return -EINVAL;
15021502

15031503
ptr = kzalloc(outlen, GFP_KERNEL);
15041504
if (!ptr)

0 commit comments

Comments
 (0)