* [PATCH net v2] net/mlx4: Check retval of mlx4_bitmap_init
@ 2022-11-16 10:08 Peter Kosyh
2022-11-17 10:39 ` Leon Romanovsky
0 siblings, 1 reply; 4+ messages in thread
From: Peter Kosyh @ 2022-11-16 10:08 UTC (permalink / raw)
To: Tariq Toukan
Cc: Peter Kosyh, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, lvc-project
If mlx4_bitmap_init fails, mlx4_bitmap_alloc_range will dereference
the NULL pointer (bitmap->table).
Make sure, that mlx4_bitmap_alloc_range called in no error case.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d57febe1a478 ("net/mlx4: Add A0 hybrid steering")
Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx4/qp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
index b149e601f673..48cfaa7eaf50 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -697,7 +697,8 @@ static int mlx4_create_zones(struct mlx4_dev *dev,
err = mlx4_bitmap_init(*bitmap + k, 1,
MLX4_QP_TABLE_RAW_ETH_SIZE - 1, 0,
0);
- mlx4_bitmap_alloc_range(*bitmap + k, 1, 1, 0);
+ if (!err)
+ mlx4_bitmap_alloc_range(*bitmap + k, 1, 1, 0);
}
if (err)
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net v2] net/mlx4: Check retval of mlx4_bitmap_init
2022-11-16 10:08 [PATCH net v2] net/mlx4: Check retval of mlx4_bitmap_init Peter Kosyh
@ 2022-11-17 10:39 ` Leon Romanovsky
2022-11-17 15:28 ` [PATCH net v3] " Peter Kosyh
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2022-11-17 10:39 UTC (permalink / raw)
To: Peter Kosyh
Cc: Tariq Toukan, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, lvc-project
On Wed, Nov 16, 2022 at 01:08:06PM +0300, Peter Kosyh wrote:
> If mlx4_bitmap_init fails, mlx4_bitmap_alloc_range will dereference
> the NULL pointer (bitmap->table).
>
> Make sure, that mlx4_bitmap_alloc_range called in no error case.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: d57febe1a478 ("net/mlx4: Add A0 hybrid steering")
>
> Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
>
> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Please don't add blank lines between tags and your Signed-off-by should
be last.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH net v3] net/mlx4: Check retval of mlx4_bitmap_init
2022-11-17 10:39 ` Leon Romanovsky
@ 2022-11-17 15:28 ` Peter Kosyh
2022-11-19 3:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 4+ messages in thread
From: Peter Kosyh @ 2022-11-17 15:28 UTC (permalink / raw)
To: Tariq Toukan
Cc: Peter Kosyh, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, lvc-project
If mlx4_bitmap_init fails, mlx4_bitmap_alloc_range will dereference
the NULL pointer (bitmap->table).
Make sure, that mlx4_bitmap_alloc_range called in no error case.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d57febe1a478 ("net/mlx4: Add A0 hybrid steering")
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
---
drivers/net/ethernet/mellanox/mlx4/qp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
index b149e601f673..48cfaa7eaf50 100644
--- a/drivers/net/ethernet/mellanox/mlx4/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
@@ -697,7 +697,8 @@ static int mlx4_create_zones(struct mlx4_dev *dev,
err = mlx4_bitmap_init(*bitmap + k, 1,
MLX4_QP_TABLE_RAW_ETH_SIZE - 1, 0,
0);
- mlx4_bitmap_alloc_range(*bitmap + k, 1, 1, 0);
+ if (!err)
+ mlx4_bitmap_alloc_range(*bitmap + k, 1, 1, 0);
}
if (err)
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net v3] net/mlx4: Check retval of mlx4_bitmap_init
2022-11-17 15:28 ` [PATCH net v3] " Peter Kosyh
@ 2022-11-19 3:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-19 3:50 UTC (permalink / raw)
To: Peter Kosyh; +Cc: tariqt, davem, edumazet, kuba, pabeni, netdev, lvc-project
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 17 Nov 2022 18:28:06 +0300 you wrote:
> If mlx4_bitmap_init fails, mlx4_bitmap_alloc_range will dereference
> the NULL pointer (bitmap->table).
>
> Make sure, that mlx4_bitmap_alloc_range called in no error case.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> [...]
Here is the summary with links:
- [net,v3] net/mlx4: Check retval of mlx4_bitmap_init
https://git.kernel.org/netdev/net/c/594c61ffc77d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-19 3:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-16 10:08 [PATCH net v2] net/mlx4: Check retval of mlx4_bitmap_init Peter Kosyh
2022-11-17 10:39 ` Leon Romanovsky
2022-11-17 15:28 ` [PATCH net v3] " Peter Kosyh
2022-11-19 3:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).