From 489bdbbfc269c819ec679605d1f0e8ad058789f4 Mon Sep 17 00:00:00 2001 From: Kalesh AP Date: Fri, 8 May 2020 10:20:24 +0530 Subject: [PATCH] app/testpmd: fix memory failure handling for i40e DDP In cmd_ddp_get_list_parsed(), elements of "p_list" are accessed even after the memory allocation for "p_list" fails. With this patch, this null pointer dereference is avoided as we return when there is malloc failure. Fixes: e088907bb851 ("app/testpmd: add command for getting loaded DDP profiles") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Acked-by: Bernard Iremonger --- app/test-pmd/cmdline.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b040630c54..996a498768 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -16891,8 +16891,10 @@ cmd_ddp_get_list_parsed( #ifdef RTE_LIBRTE_I40E_PMD size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); - if (!p_list) + if (!p_list) { printf("%s: Failed to malloc buffer\n", __func__); + return; + } if (ret == -ENOTSUP) ret = rte_pmd_i40e_get_ddp_list(res->port_id, -- 2.20.1