Skip to contentSkip to conversation

test: fix flow classifier creating failure

PATCH In review Min Hu (Connor) 2 participants 2 messages Apr 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: fix flow classifier creating failure

'cls->cls' will be NULL if flow classifier create has failed, then segmentation fault will occur if the variable is used.

This patch fixed it.

Fixes 9c9befea4f57 ("test: add flow classify unit tests")
---
 app/test/test_flow_classify.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test/test_flow_classify.c +6 -0
index ef0b6fd..951606f 100644
@@ -828,6 +828,12 @@ test_flow_classify(void)
 	cls_params.name = "flow_classifier";
 	cls_params.socket_id = 0;
 	cls->cls = rte_flow_classifier_create(&cls_params);
+	if (cls->cls == NULL) {
+		printf("Line %i: flow classifier create has failed!\n",
+		       __LINE__);
+		rte_free(cls);
+		return TEST_FAILED;
+	}
 
 	/* initialise ACL table params */
 	table_acl_params.n_rule_fields = RTE_DIM(ipv4_defs);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Min Hu (Connor) <[email protected]>
Sent: Thursday, April 22, 2021 7:14 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>; Iremonger, Bernard <[email protected]>
Subject: [PATCH] test: fix flow classifier creating failure

'cls->cls' will be NULL if flow classifier create has failed, then segmentation fault will occur if the variable is used.

Quoted 6 lines

This patch fixed it.

Fixes 9c9befea4f57 ("test: add flow classify unit tests")