diff mbox series

[05/10] app/test: add null pointer check of memory allocation

Message ID 1618839289-33224-6-git-send-email-humin29@huawei.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers show
Series fixes for clean code | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) April 19, 2021, 1:34 p.m. UTC
From: HongBo Zheng <zhenghongbo3@huawei.com>

The rte_zmalloc is called in test_crc_calc without null pointer
check. This patch adds null pointer checks on return value of
rte_zmalloc.

Fixes: 9c77b848b1c1 ("test: add CRC computation")
Cc: stable@dpdk.org

Signed-off-by: HongBo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 app/test/test_crc.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/app/test/test_crc.c b/app/test/test_crc.c
index bf1d344..8231f81 100644
--- a/app/test/test_crc.c
+++ b/app/test/test_crc.c
@@ -80,6 +80,8 @@  test_crc_calc(void)
 
 	/* 32-bit ethernet CRC: Test 2 */
 	test_data = rte_zmalloc(NULL, CRC32_VEC_LEN1, 0);
+	if (test_data == NULL)
+		return -7;
 
 	for (i = 0; i < CRC32_VEC_LEN1; i += 12)
 		rte_memcpy(&test_data[i], crc32_vec1, 12);