DPDK patches and discussions
 help / color / mirror / Atom feed
From: Simei Su <simei.su@intel.com>
To: qi.z.zhang@intel.com
Cc: dev@dpdk.org, wenjun1.wu@intel.com, Simei Su <simei.su@intel.com>
Subject: [dpdk-dev] [PATCH] net/ice: fix dereferenced null pointer
Date: Mon, 11 Oct 2021 16:25:25 +0800	[thread overview]
Message-ID: <20211011082525.87965-1-simei.su@intel.com> (raw)

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(-)

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
-- 
2.9.5


             reply	other threads:[~2021-10-11  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11  8:25 Simei Su [this message]
2021-10-14  6:26 ` Zhang, Qi Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211011082525.87965-1-simei.su@intel.com \
    --to=simei.su@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=wenjun1.wu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).