* [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table()
@ 2025-03-07 2:18 Wentao Liang
2025-03-07 13:45 ` [PATCH net v4?] " Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wentao Liang @ 2025-03-07 2:18 UTC (permalink / raw)
To: saeedm, leon, tariqt, andrew+netdev, davem, edumazet, kuba,
pabeni
Cc: netdev, linux-rdma, linux-kernel, Wentao Liang
In mlx5_chains_create_table(), the return value of mlx5_get_fdb_sub_ns()
and mlx5_get_flow_namespace() must be checked to prevent NULL pointer
dereferences. If either function fails, the function should log error
message with mlx5_core_warn() and return error pointer.
Fixes: 39ac237ce009 ("net/mlx5: E-Switch, Refactor chains and priorities")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
[v1]->[v2]: Add Fixes tag and branch target. Change return value.
[v2]->[v3]: Change Fixes tag. Move change history.
---
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
index a80ecb672f33..711d14dea248 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
@@ -196,6 +196,11 @@ mlx5_chains_create_table(struct mlx5_fs_chains *chains,
ns = mlx5_get_flow_namespace(chains->dev, chains->ns);
}
+ if (!ns) {
+ mlx5_core_warn(chains->dev, "Failed to get flow namespace\n");
+ return ERR_PTR(-EOPNOTSUPP);
+ }
+
ft_attr.autogroup.num_reserved_entries = 2;
ft_attr.autogroup.max_num_groups = chains->group_num;
ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
--
2.42.0.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net v4?] net/mlx5: handle errors in mlx5_chains_create_table()
2025-03-07 2:18 [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table() Wentao Liang
@ 2025-03-07 13:45 ` Markus Elfring
2025-03-09 11:46 ` [PATCH net v3] " Tariq Toukan
2025-03-10 20:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-03-07 13:45 UTC (permalink / raw)
To: vulab, linux-rdma, netdev
Cc: LKML, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Leon Romanovsky, Paolo Abeni, Saeed Mahameed, Tariq Toukan
I suggest to reconsider the patch version number selection once more.
> In mlx5_chains_create_table(), the return value of mlx5_get_fdb_sub_ns()
> and mlx5_get_flow_namespace() must be checked to prevent NULL pointer
> dereferences. If either function fails, the function should log error
> message with mlx5_core_warn() and return error pointer.
Please improve such a change description another bit.
See also:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14-rc5#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table()
2025-03-07 2:18 [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table() Wentao Liang
2025-03-07 13:45 ` [PATCH net v4?] " Markus Elfring
@ 2025-03-09 11:46 ` Tariq Toukan
2025-03-10 20:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Tariq Toukan @ 2025-03-09 11:46 UTC (permalink / raw)
To: Wentao Liang, saeedm, leon, andrew+netdev, davem, edumazet, kuba,
pabeni
Cc: netdev, linux-rdma, linux-kernel, Tariq Toukan
On 07/03/2025 4:18, Wentao Liang wrote:
> In mlx5_chains_create_table(), the return value of mlx5_get_fdb_sub_ns()
> and mlx5_get_flow_namespace() must be checked to prevent NULL pointer
> dereferences. If either function fails, the function should log error
> message with mlx5_core_warn() and return error pointer.
>
> Fixes: 39ac237ce009 ("net/mlx5: E-Switch, Refactor chains and priorities")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> [v1]->[v2]: Add Fixes tag and branch target. Change return value.
> [v2]->[v3]: Change Fixes tag. Move change history.
> ---
> drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
> index a80ecb672f33..711d14dea248 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
> @@ -196,6 +196,11 @@ mlx5_chains_create_table(struct mlx5_fs_chains *chains,
> ns = mlx5_get_flow_namespace(chains->dev, chains->ns);
> }
>
> + if (!ns) {
> + mlx5_core_warn(chains->dev, "Failed to get flow namespace\n");
> + return ERR_PTR(-EOPNOTSUPP);
> + }
> +
> ft_attr.autogroup.num_reserved_entries = 2;
> ft_attr.autogroup.max_num_groups = chains->group_num;
> ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table()
2025-03-07 2:18 [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table() Wentao Liang
2025-03-07 13:45 ` [PATCH net v4?] " Markus Elfring
2025-03-09 11:46 ` [PATCH net v3] " Tariq Toukan
@ 2025-03-10 20:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-10 20:10 UTC (permalink / raw)
To: Wentao Liang
Cc: saeedm, leon, tariqt, andrew+netdev, davem, edumazet, kuba,
pabeni, netdev, linux-rdma, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 7 Mar 2025 10:18:20 +0800 you wrote:
> In mlx5_chains_create_table(), the return value of mlx5_get_fdb_sub_ns()
> and mlx5_get_flow_namespace() must be checked to prevent NULL pointer
> dereferences. If either function fails, the function should log error
> message with mlx5_core_warn() and return error pointer.
>
> Fixes: 39ac237ce009 ("net/mlx5: E-Switch, Refactor chains and priorities")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
>
> [...]
Here is the summary with links:
- [net,v3] net/mlx5: handle errors in mlx5_chains_create_table()
https://git.kernel.org/netdev/net/c/eab0396353be
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:[~2025-03-10 20:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07 2:18 [PATCH net v3] net/mlx5: handle errors in mlx5_chains_create_table() Wentao Liang
2025-03-07 13:45 ` [PATCH net v4?] " Markus Elfring
2025-03-09 11:46 ` [PATCH net v3] " Tariq Toukan
2025-03-10 20:10 ` 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).