patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Steve Yang <stevex.yang@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, qi.z.zhang@intel.com,
	Steve Yang <stevex.yang@intel.com>,
	stable@dpdk.org
Subject: [PATCH v1] net/ice: fix dereference before null check
Date: Mon,  7 Feb 2022 08:25:58 +0000	[thread overview]
Message-ID: <20220207082558.1349140-1-stevex.yang@intel.com> (raw)

This patch fixes coverity issue by assigning the address
of the "info->data" without "info" pointer check.

CID 375065:  Null pointer dereferences  (REVERSE_INULL)
Null-checking "info" suggests that it may be null, but it has already been
dereferenced on all paths leading to the check.

Coverity issue: 375065
Fixes: fd8480e61490 ("net/ice: support module EEPROM")
Cc: stable@dpdk.org

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index d01acb8797..1a469afeac 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5016,14 +5016,14 @@ ice_get_module_eeprom(struct rte_eth_dev *dev,
 #define I2C_USLEEP_MAX_TIME 2500
 	uint8_t value[SFF_READ_BLOCK_SIZE] = {0};
 	uint8_t addr = ICE_I2C_EEPROM_DEV_ADDR;
-	uint8_t *data = info->data;
+	uint8_t *data = NULL;
 	enum ice_status status;
 	bool is_sfp = false;
 	uint32_t i, j;
 	uint32_t offset = 0;
 	uint8_t page = 0;
 
-	if (!info || !info->length || !data)
+	if (!info || !info->length || !info->data)
 		return -EINVAL;
 
 	status = ice_aq_sff_eeprom(hw, 0, addr, offset, page, 0, value, 1, 0,
@@ -5034,6 +5034,7 @@ ice_get_module_eeprom(struct rte_eth_dev *dev,
 	if (value[0] == ICE_MODULE_TYPE_SFP)
 		is_sfp = true;
 
+	data = info->data;
 	memset(data, 0, info->length);
 	for (i = 0; i < info->length; i += SFF_READ_BLOCK_SIZE) {
 		offset = i + info->offset;
-- 
2.27.0


             reply	other threads:[~2022-02-07  8:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07  8:25 Steve Yang [this message]
2022-02-09  1:42 ` 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=20220207082558.1349140-1-stevex.yang@intel.com \
    --to=stevex.yang@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stable@dpdk.org \
    /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).