test: check memory allocation for CRC
authorHongbo Zheng <zhenghongbo3@huawei.com>
Mon, 19 Apr 2021 13:34:44 +0000 (21:34 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 26 Jun 2022 17:53:05 +0000 (19:53 +0200)
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

index 0ed080e..5edc8fb 100644 (file)
@@ -79,6 +79,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);