[v3] app/testpmd: fix null pointer dereferencing issue

Message ID 20200508045024.19739-1-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v3] app/testpmd: fix null pointer dereferencing issue |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-nxp-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues

Commit Message

Kalesh A P May 8, 2020, 4:50 a.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

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 <kalesh-anakkur.purayil@broadcom.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
v3: fixed commit message as suggested by Bernard Iremonger
v2: fixed headline case

 app/test-pmd/cmdline.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit May 8, 2020, 3:13 p.m. UTC | #1
On 5/8/2020 5:50 AM, Kalesh A P wrote:
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> 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 <kalesh-anakkur.purayil@broadcom.com>
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b040630..996a498 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,