diff mbox series

test: fix flow classifier creating failure

Message ID 1619072034-36817-1-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers show
Series test: fix flow classifier creating failure | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) April 22, 2021, 6:13 a.m. UTC
'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")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 app/test/test_flow_classify.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Iremonger, Bernard April 22, 2021, 9:51 a.m. UTC | #1
> -----Original Message-----
> From: Min Hu (Connor) <humin29@huawei.com>
> Sent: Thursday, April 22, 2021 7:14 AM
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> 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.
> 
> This patch fixed it.
> 
> Fixes: 9c9befea4f57 ("test: add flow classify unit tests")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
diff mbox series

Patch

diff --git a/app/test/test_flow_classify.c b/app/test/test_flow_classify.c
index ef0b6fd..951606f 100644
--- a/app/test/test_flow_classify.c
+++ b/app/test/test_flow_classify.c
@@ -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);