net/ice: fix dereferenced null pointer

Message ID 20211011082525.87965-1-simei.su@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/ice: fix dereferenced null pointer |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Simei Su Oct. 11, 2021, 8:25 a.m. UTC
  This patch fixes coverity issue by avoiding use of null pointer
in taking false branch.

Coverity issue: 373360
Fixes: 437dbd2fd428 ("net/ice: support 1PPS")

Signed-off-by: Simei Su <simei.su@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
  

Comments

Qi Zhang Oct. 14, 2021, 6:26 a.m. UTC | #1
> -----Original Message-----
> From: Su, Simei <simei.su@intel.com>
> Sent: Monday, October 11, 2021 4:25 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Wu, Wenjun1 <wenjun1.wu@intel.com>; Su, Simei
> <simei.su@intel.com>
> Subject: [PATCH] net/ice: fix dereferenced null pointer
> 
> This patch fixes coverity issue by avoiding use of null pointer in taking false
> branch.
> 
> Coverity issue: 373360
> Fixes: 437dbd2fd428 ("net/ice: support 1PPS")
> 
> Signed-off-by: Simei Su <simei.su@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 65e43a1..170a127 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -1854,18 +1854,18 @@  parse_pin_set(const char *input, int pps_type, struct ice_devargs *devargs)
 		idx = strtoul(str, &end, 10);
 		if (end == NULL || idx >= ICE_MAX_PIN_NUM)
 			return -1;
+		while (isblank(*end))
+			end++;
+		if (*end != ']')
+			return -1;
 
 		devargs->pin_idx = idx;
 		devargs->pps_out_ena = 1;
-	}
-
-	while (isblank(*end))
-		end++;
 
-	if (*end != ']')
-		return -1;
+		return 0;
+	}
 
-	return 0;
+	return -1;
 }
 
 static int