* [PATCH net] net/mlx5: Fix uninitialized variable bug in outlen_write()
@ 2022-11-21 11:22 YueHaibing
2022-11-22 13:06 ` Leon Romanovsky
2022-11-23 5:01 ` Saeed Mahameed
0 siblings, 2 replies; 3+ messages in thread
From: YueHaibing @ 2022-11-21 11:22 UTC (permalink / raw)
To: saeedm, leon, davem, edumazet, kuba, pabeni, moshe, ogerlitz,
eli, jackm, roland
Cc: netdev, linux-rdma, linux-kernel, YueHaibing
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>
---
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 ++--
1 file 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 2e0d59ca62b5..cfb1e9f18a6c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1508,8 +1508,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)
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net/mlx5: Fix uninitialized variable bug in outlen_write()
2022-11-21 11:22 [PATCH net] net/mlx5: Fix uninitialized variable bug in outlen_write() YueHaibing
@ 2022-11-22 13:06 ` Leon Romanovsky
2022-11-23 5:01 ` Saeed Mahameed
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-11-22 13:06 UTC (permalink / raw)
To: YueHaibing
Cc: saeedm, davem, edumazet, kuba, pabeni, moshe, ogerlitz, eli,
jackm, roland, netdev, linux-rdma, linux-kernel
On Mon, Nov 21, 2022 at 07:22:04PM +0800, YueHaibing wrote:
> 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>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net/mlx5: Fix uninitialized variable bug in outlen_write()
2022-11-21 11:22 [PATCH net] net/mlx5: Fix uninitialized variable bug in outlen_write() YueHaibing
2022-11-22 13:06 ` Leon Romanovsky
@ 2022-11-23 5:01 ` Saeed Mahameed
1 sibling, 0 replies; 3+ messages in thread
From: Saeed Mahameed @ 2022-11-23 5:01 UTC (permalink / raw)
To: YueHaibing
Cc: saeedm, leon, davem, edumazet, kuba, pabeni, moshe, ogerlitz,
eli, jackm, roland, netdev, linux-rdma, linux-kernel
On 21 Nov 19:22, YueHaibing wrote:
>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>
>
applied to net-mlx5, thanks !
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-23 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 11:22 [PATCH net] net/mlx5: Fix uninitialized variable bug in outlen_write() YueHaibing
2022-11-22 13:06 ` Leon Romanovsky
2022-11-23 5:01 ` Saeed Mahameed
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.