Skip to contentSkip to conversation

net/mlx5/hws: check action creation for HWS support

PATCH Superseded Alex Vesker 2 participants 3 messages Nov 3, 2022 – Nov 8, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5/hws: check action creation for HWS support

Fix segmentation fault when user will request to allocate a HWS action while current device doesn't support HWS.

Fixes f8c8a6d ("net/mlx5/hws: add action object")
---
 drivers/net/mlx5/hws/mlx5dr_action.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mlx5/hws/mlx5dr_action.c +7 -0
index 755d5d09cf..a0c34c3e35 100644
@@ -699,6 +699,13 @@ mlx5dr_action_create_generic(struct mlx5dr_context *ctx,
 		return NULL;
 	}
 
+	if (mlx5dr_action_is_hws_flags(flags) &&
+	    !(ctx->flags & MLX5DR_CONTEXT_FLAG_HWS_SUPPORT)) {
+		DR_LOG(ERR, "Cannot create HWS action since HWS is not supported");
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
+
 	action = simple_calloc(1, sizeof(*action));
 	if (!action) {
 		DR_LOG(ERR, "Failed to allocate memory for action [%d]", action_type);
Signature · 1 line
2.18.1
#1 lore raw

PATCH v2 1/1 net/mlx5/hws: fix action creation check for HWS support

Fix segmentation fault when a user will request to allocate a HWS action while current device doesn't support HWS.

Fixes f8c8a6d ("net/mlx5/hws: add action object")
---
 drivers/net/mlx5/hws/mlx5dr_action.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mlx5/hws/mlx5dr_action.c +7 -0
index a9e12aa1f5..b0ae4e7693 100644
@@ -697,6 +697,13 @@ mlx5dr_action_create_generic(struct mlx5dr_context *ctx,
 		return NULL;
 	}
 
+	if (mlx5dr_action_is_hws_flags(flags) &&
+	    !(ctx->flags & MLX5DR_CONTEXT_FLAG_HWS_SUPPORT)) {
+		DR_LOG(ERR, "Cannot create HWS action since HWS is not supported");
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
+
 	action = simple_calloc(1, sizeof(*action));
 	if (!action) {
 		DR_LOG(ERR, "Failed to allocate memory for action [%d]", action_type);
Signature · 1 line
2.18.1
#2 lore raw

RE: [PATCH v2] net/mlx5/hws: fix action creation check for HWS support

Hi,

Quoted 10 lines

-----Original Message-----
From: Alex Vesker <[email protected]>
Sent: Monday, November 7, 2022 1:04 PM
To: Alex Vesker <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>
Subject: [PATCH v2] net/mlx5/hws: fix action creation check for HWS support

Quoted 8 lines

Fix segmentation fault when a user will request to allocate a HWS action while current device doesn't support HWS.

Fixes f8c8a6d ("net/mlx5/hws: add action object")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh