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

Message ID 20200507110611.30877-1-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] 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/iol-nxp-Performance success Performance Testing PASS
ci/travis-robot warning Travis build: failed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing fail Testing issues

Commit Message

Kalesh A P May 7, 2020, 11:06 a.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Note that the issue was observed in an internal Coverity scan.

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>
---
v2: fixed headline case

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

Comments

Iremonger, Bernard May 7, 2020, 1:21 p.m. UTC | #1
Hi Kalesh,

> -----Original Message-----
> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
> Sent: Thursday, May 7, 2020 12:06 PM
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Iremonger,
> Bernard <bernard.iremonger@intel.com>
> Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix null pointer dereferencing
> issue
> 
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> Note that the issue was observed in an internal Coverity scan.
> 
> 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>
> ---
> v2: fixed headline case
> 
>  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
> 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,
> --
> 2.10.1

./devtools/check-git-log.sh 
Missing 'Coverity issue:' tag:
        app/testpmd: fix null pointer dereferencing issue

As there is no Coverity issue tag for this bug, then best not to mention Coverity in the commit message.
An explanation of the fix should be added to the commit message.
How the bug was found is not relevant to the commit message.

Otherwise

Acked-by Bernard Iremonger <bernard.iremonger@intel.com>
  

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,