diff options
author | YueHaibing <yuehaibing@huawei.com> | 2022-11-21 19:22:04 +0800 |
---|---|---|
committer | Saeed Mahameed <saeedm@nvidia.com> | 2022-11-24 00:03:21 -0800 |
commit | 3f5769a074c13d8f08455e40586600419e02a880 (patch) | |
tree | e3096929b66f2e9bdbc3ce4a57b253c9e3c8764c /drivers | |
parent | e87c6a832f889c093c055a30a7b8c6843e6573bf (diff) | |
download | linux-3f5769a074c13d8f08455e40586600419e02a880.tar.gz |
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: e126ba97dba9 ("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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index 74bd05e5dda2..e7a894ba5c3e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -1497,8 +1497,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) |