DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	stable@dpdk.org, zijie.pan@6wind.com,
	Beilei Xing <beilei.xing@intel.com>,
	Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH 5/5] net/i40e: fix dereference before check when getting EEPROM
Date: Fri,  5 Apr 2019 14:45:11 +0100	[thread overview]
Message-ID: <20190405134511.49066-6-bruce.richardson@intel.com> (raw)
In-Reply-To: <20190405134511.49066-1-bruce.richardson@intel.com>

As flagged by coverity, the "info" structure is being explicitly
dereferenced before being checked later for a NULL value.

Coverity issue: 277241
Fixes: 98e60c0d43f1 ("net/i40e: add module EEPROM callbacks for i40e")
CC: stable@dpdk.org
Cc: zijie.pan@6wind.com
CC: Beilei Xing <beilei.xing@intel.com>
CC: Qi Zhang <qi.z.zhang@intel.com>

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index b031bf4c6..6450af016 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -11893,16 +11893,17 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev,
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	bool is_sfp = false;
 	i40e_status status;
-	uint8_t *data = info->data;
+	uint8_t *data;
 	uint32_t value = 0;
 	uint32_t i;
 
-	if (!info || !info->length || !data)
+	if (!info || !info->length || !info->data)
 		return -EINVAL;
 
 	if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP)
 		is_sfp = true;
 
+	data = info->data;
 	for (i = 0; i < info->length; i++) {
 		u32 offset = i + info->offset;
 		u32 addr = is_sfp ? I40E_I2C_EEPROM_DEV_ADDR : 0;
-- 
2.20.1

  parent reply	other threads:[~2019-04-05 13:45 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-05 13:45 [dpdk-dev] [PATCH 0/5] some small fixes Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 13:45 ` [dpdk-dev] [PATCH 1/5] examples/vhost_scsi: fix header check for meson build Bruce Richardson
2019-04-05 13:45   ` Bruce Richardson
2019-04-05 13:45 ` [dpdk-dev] [PATCH 2/5] examples/vhost_scsi: fix missing NULL-check for parameter Bruce Richardson
2019-04-05 13:45   ` Bruce Richardson
2019-04-05 13:45 ` [dpdk-dev] [PATCH 3/5] net/i40e: fix dereference before NULL check in mbuf release Bruce Richardson
2019-04-05 13:45   ` Bruce Richardson
2019-04-05 14:08   ` Rami Rosen
2019-04-05 14:08     ` Rami Rosen
2019-04-05 13:45 ` [dpdk-dev] [PATCH 4/5] app/testpmd: fix variable use before NULL check Bruce Richardson
2019-04-05 13:45   ` Bruce Richardson
2019-04-05 14:13   ` Rami Rosen
2019-04-05 14:13     ` Rami Rosen
2019-04-05 13:45 ` Bruce Richardson [this message]
2019-04-05 13:45   ` [dpdk-dev] [PATCH 5/5] net/i40e: fix dereference before check when getting EEPROM Bruce Richardson
2019-04-05 14:19   ` Rami Rosen
2019-04-05 14:19     ` Rami Rosen
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 0/5] some small fixes Bruce Richardson
2019-04-05 14:37   ` Bruce Richardson
2019-04-05 14:37   ` [dpdk-dev] [PATCH v2 1/5] examples/vhost_scsi: fix header check for meson build Bruce Richardson
2019-04-05 14:37     ` Bruce Richardson
2019-04-08  3:23     ` Tiwei Bie
2019-04-08  3:23       ` Tiwei Bie
2019-04-05 14:37   ` [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter Bruce Richardson
2019-04-05 14:37     ` Bruce Richardson
2019-04-08  3:31     ` Tiwei Bie
2019-04-08  3:31       ` Tiwei Bie
2019-04-08  9:37       ` Bruce Richardson
2019-04-08  9:37         ` Bruce Richardson
2019-04-05 14:37   ` [dpdk-dev] [PATCH v2 3/5] net/i40e: fix dereference before NULL check in mbuf release Bruce Richardson
2019-04-05 14:37     ` Bruce Richardson
2019-04-05 14:37   ` [dpdk-dev] [PATCH v2 4/5] app/testpmd: fix variable use before NULL check Bruce Richardson
2019-04-05 14:37     ` Bruce Richardson
2019-04-05 14:37   ` [dpdk-dev] [PATCH v2 5/5] net/i40e: fix dereference before check when getting EEPROM Bruce Richardson
2019-04-05 14:37     ` Bruce Richardson
2019-04-08  9:46 ` [dpdk-dev] [PATCH v3 0/5] some small fixes Bruce Richardson
2019-04-08  9:46   ` Bruce Richardson
2019-04-08  9:46   ` [dpdk-dev] [PATCH v3 1/5] examples/vhost_scsi: fix header check for meson build Bruce Richardson
2019-04-08  9:46     ` Bruce Richardson
2019-04-08  9:46   ` [dpdk-dev] [PATCH v3 2/5] examples/vhost_scsi: fix missing NULL-check for parameter Bruce Richardson
2019-04-08  9:46     ` Bruce Richardson
2019-04-09  1:53     ` Tiwei Bie
2019-04-09  1:53       ` Tiwei Bie
2019-04-08  9:46   ` [dpdk-dev] [PATCH v3 3/5] net/i40e: fix dereference before NULL check in mbuf release Bruce Richardson
2019-04-08  9:46     ` Bruce Richardson
2019-04-08  9:46   ` [dpdk-dev] [PATCH v3 4/5] app/testpmd: fix variable use before NULL check Bruce Richardson
2019-04-08  9:46     ` Bruce Richardson
2019-04-08  9:46   ` [dpdk-dev] [PATCH v3 5/5] net/i40e: fix dereference before check when getting EEPROM Bruce Richardson
2019-04-08  9:46     ` Bruce Richardson
2019-04-22 21:49   ` [dpdk-dev] [PATCH v3 0/5] some small fixes Thomas Monjalon
2019-04-22 21:49     ` Thomas Monjalon

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=20190405134511.49066-6-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=stable@dpdk.org \
    --cc=zijie.pan@6wind.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).