DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2] net/ice: fix possible null pointer dereference
Date: Wed, 24 Apr 2019 10:43:42 +0800	[thread overview]
Message-ID: <1556073822-50250-1-git-send-email-wenzhuo.lu@intel.com> (raw)
Message-ID: <20190424024342.ZlDiEU3-Li1nZgfK5wTi4c9z7wES37lZqhf80OHNn9c@z> (raw)
In-Reply-To: <1555551081-29524-1-git-send-email-wenzhuo.lu@intel.com>

Fix the issues reported by Coverity check, "Null-checking
vsi suggests that it may be null, but it has already been
dereferenced on all paths leading to the check."

Coverity issue: 328509
Coverity issue: 328519
Coverity issue: 328523
Fixes: e0dcf94a0d7f ("net/ice: support VLAN ops")
Fixes: ff963bfa7cb1 ("net/ice: support RSS")
Cc: stable@dpdk.org

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
Reviewed-by: Rami Rosen <ramirose@gmail.com>
---
 drivers/net/ice/ice_ethdev.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0946b19..5cca4a8 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -645,12 +645,14 @@ struct ice_xstats_name_off {
 	struct ice_fltr_list_entry *v_list_itr = NULL;
 	struct ice_vlan_filter *f;
 	struct LIST_HEAD_TYPE list_head;
-	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_hw *hw;
 	int ret = 0;
 
 	if (!vsi || vlan_id > ETHER_MAX_VLAN_ID)
 		return -EINVAL;
 
+	hw = ICE_VSI_TO_HW(vsi);
+
 	/* If it's added and configured, return. */
 	f = ice_find_vlan_filter(vsi, vlan_id);
 	if (f) {
@@ -710,7 +712,7 @@ struct ice_xstats_name_off {
 	struct ice_fltr_list_entry *v_list_itr = NULL;
 	struct ice_vlan_filter *f;
 	struct LIST_HEAD_TYPE list_head;
-	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_hw *hw;
 	int ret = 0;
 
 	/**
@@ -720,6 +722,8 @@ struct ice_xstats_name_off {
 	if (!vsi || vlan_id == 0 || vlan_id > ETHER_MAX_VLAN_ID)
 		return -EINVAL;
 
+	hw = ICE_VSI_TO_HW(vsi);
+
 	/* Can't find it, return an error */
 	f = ice_find_vlan_filter(vsi, vlan_id);
 	if (!f)
@@ -2553,13 +2557,16 @@ static int ice_macaddr_set(struct rte_eth_dev *dev,
 static int
 ice_set_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size)
 {
-	struct ice_pf *pf = ICE_VSI_TO_PF(vsi);
-	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	struct ice_pf *pf;
+	struct ice_hw *hw;
 	int ret;
 
 	if (!vsi || !lut)
 		return -EINVAL;
 
+	pf = ICE_VSI_TO_PF(vsi);
+	hw = ICE_VSI_TO_HW(vsi);
+
 	if (pf->flags & ICE_FLAG_RSS_AQ_CAPABLE) {
 		ret = ice_aq_set_rss_lut(hw, vsi->idx, TRUE,
 					 lut, lut_size);
-- 
1.9.3


  parent reply	other threads:[~2019-04-24  2:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18  1:31 [dpdk-dev] [PATCH] net/ice: fix coverity issues Wenzhuo Lu
2019-04-18  1:31 ` Wenzhuo Lu
2019-04-22  6:57 ` Yang, Qiming
2019-04-22  6:57   ` Yang, Qiming
2019-04-22  7:14   ` Rami Rosen
2019-04-22  7:14     ` Rami Rosen
2019-04-23  3:29   ` Zhang, Qi Z
2019-04-23  3:29     ` Zhang, Qi Z
2019-04-23 10:40 ` Ferruh Yigit
2019-04-23 10:40   ` Ferruh Yigit
2019-04-24  2:15   ` Lu, Wenzhuo
2019-04-24  2:15     ` Lu, Wenzhuo
2019-04-24  2:43 ` Wenzhuo Lu [this message]
2019-04-24  2:43   ` [dpdk-dev] [PATCH v2] net/ice: fix possible null pointer dereference Wenzhuo Lu
2019-04-24 15:56   ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2019-04-24 15:56     ` Ferruh Yigit

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=1556073822-50250-1-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=dev@dpdk.org \
    --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).