netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx5e: fix potential null dereference in mlx5e_tc_nic_create_miss_table
@ 2025-04-02  9:32 Charles Han
  2025-04-03 18:28 ` Tariq Toukan
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Han @ 2025-04-02  9:32 UTC (permalink / raw)
  To: saeedm, tariqt, leon, andrew+netdev, davem, edumazet, kuba,
	pabeni, maord, lariel, paulb
  Cc: netdev, linux-rdma, linux-kernel, Charles Han

mlx5_get_flow_namespace() may return a NULL pointer, dereferencing it
without NULL check may lead to NULL dereference.
Add a NULL check for ns.

Fixes: 66cb64e292d2 ("net/mlx5e: TC NIC mode, fix tc chains miss table")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9ba99609999f..9c524d8c0e5a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -5216,6 +5216,10 @@ static int mlx5e_tc_nic_create_miss_table(struct mlx5e_priv *priv)
 	ft_attr.level = MLX5E_TC_MISS_LEVEL;
 	ft_attr.prio = 0;
 	ns = mlx5_get_flow_namespace(priv->mdev, MLX5_FLOW_NAMESPACE_KERNEL);
+	if (!ns) {
+		mlx5_core_warn(priv->mdev, "Failed to get flow namespace\n");
+		return -EOPNOTSUPP;
+	}
 
 	*ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
 	if (IS_ERR(*ft)) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-04-09 14:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02  9:32 [PATCH] net/mlx5e: fix potential null dereference in mlx5e_tc_nic_create_miss_table Charles Han
2025-04-03 18:28 ` Tariq Toukan
2025-04-07  7:20   ` [PATCH V2] " Charles Han
2025-04-07  9:29     ` Tariq Toukan
2025-04-08  7:06       ` Charles Han
2025-04-08 15:16         ` Mark Bloch
2025-04-07 16:18     ` Simon Horman
2025-04-09 14:16     ` Tariq Toukan

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).