DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] net/ice: fix dereference before null check
@ 2022-02-07  8:25 Steve Yang
  2022-02-09  1:42 ` Zhang, Qi Z
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Yang @ 2022-02-07  8:25 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, qi.z.zhang, Steve Yang, stable

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-09  1:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07  8:25 [PATCH v1] net/ice: fix dereference before null check Steve Yang
2022-02-09  1:42 ` Zhang, Qi Z

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