* [PATCH net v2] net/mlx5: handle errors in mlx5_chains_create_table()
@ 2025-03-06 8:54 Wentao Liang
2025-03-06 9:19 ` Tariq Toukan
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-03-06 8:54 UTC (permalink / raw)
To: saeedm, leon, tariqt, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-rdma, linux-kernel, Wentao Liang, stable
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.
[v1]->[v2]:
Add Fixes tag.
Target patch to net.
Change return value from NULL to ERR_PTR(-EOPNOTSUPP)
Fixes: ae430332557a ("net/mlx5: Refactor multi chains and prios support")
Cc: stable@vger.kernel.org # 5.10+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
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 [flat|nested] 2+ messages in thread
* Re: [PATCH net v2] net/mlx5: handle errors in mlx5_chains_create_table()
2025-03-06 8:54 [PATCH net v2] net/mlx5: handle errors in mlx5_chains_create_table() Wentao Liang
@ 2025-03-06 9:19 ` Tariq Toukan
0 siblings, 0 replies; 2+ messages in thread
From: Tariq Toukan @ 2025-03-06 9:19 UTC (permalink / raw)
To: Wentao Liang, saeedm, leon, tariqt, andrew+netdev, davem,
edumazet, kuba, pabeni
Cc: netdev, linux-rdma, linux-kernel, stable
On 06/03/2025 10:54, 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.
>
> [v1]->[v2]:
> Add Fixes tag.
> Target patch to net.
> Change return value from NULL to ERR_PTR(-EOPNOTSUPP)
>
Change history should not be part of the commit message.
Please move it to under the "---" marker below.
> Fixes: ae430332557a ("net/mlx5: Refactor multi chains and prios support")
Same problem existed also in mlx5_esw_chains_create_fdb_table(), before
the refactoring.
Please refer to the original patch where issue was introduced, seems to
be commit 39ac237ce009 ("net/mlx5: E-Switch, Refactor chains and
priorities").
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-06 9:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-06 8:54 [PATCH net v2] net/mlx5: handle errors in mlx5_chains_create_table() Wentao Liang
2025-03-06 9:19 ` Tariq Toukan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®