net/ice: fix dereference before null check
PATCH 1/1 net/ice: fix dereference before null check
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
--- drivers/net/ice/ice_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ice/ice_ethdev.c +3 -2
@@ -5016,14 +5016,14 @@ ice_get_module_eeprom(struct rte_eth_dev *dev,#define I2C_USLEEP_MAX_TIME 2500uint8_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;
Signature · 1 line
2.27.0
Quoted 18 lines
-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Monday, February 7, 2022 4:26 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, SteveX <[email protected]>; [email protected]
Subject: [PATCH v1] net/ice: fix dereference before null checkThis 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.
Quoted 5 lines
Coverity issue: 375065
Fixes fd8480e61490 ("net/ice: support module EEPROM")Signed-off-by Steve Yang <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi