All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: "Jacek Bułatek" <jacekx.bulatek@intel.com>,
	netdev@vger.kernel.org, sassmann@redhat.com,
	anthony.l.nguyen@intel.com, "Haiyue Wang" <haiyue.wang@intel.com>,
	"Tony Brelinski" <tonyx.brelinski@intel.com>
Subject: [PATCH net 7/9] ice: Fix for dereference of NULL pointer
Date: Mon, 29 Mar 2021 13:18:55 -0700	[thread overview]
Message-ID: <20210329201857.3509461-8-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20210329201857.3509461-1-anthony.l.nguyen@intel.com>

From: Jacek Bułatek <jacekx.bulatek@intel.com>

Add handling of allocation fault for ice_vsi_list_map_info.

Also *fi should not be NULL pointer, it is a reference to raw
data field, so remove this variable and use the reference
directly.

Fixes: 9daf8208dd4d ("ice: Add support for switch filter programming")
Signed-off-by: Jacek Bułatek <jacekx.bulatek@intel.com>
Co-developed-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_switch.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index 67c965a3f5d2..387d3f6cd71e 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -1238,6 +1238,9 @@ ice_add_update_vsi_list(struct ice_hw *hw,
 			ice_create_vsi_list_map(hw, &vsi_handle_arr[0], 2,
 						vsi_list_id);
 
+		if (!m_entry->vsi_list_info)
+			return ICE_ERR_NO_MEMORY;
+
 		/* If this entry was large action then the large action needs
 		 * to be updated to point to FWD to VSI list
 		 */
@@ -2220,6 +2223,7 @@ ice_vsi_uses_fltr(struct ice_fltr_mgmt_list_entry *fm_entry, u16 vsi_handle)
 	return ((fm_entry->fltr_info.fltr_act == ICE_FWD_TO_VSI &&
 		 fm_entry->fltr_info.vsi_handle == vsi_handle) ||
 		(fm_entry->fltr_info.fltr_act == ICE_FWD_TO_VSI_LIST &&
+		 fm_entry->vsi_list_info &&
 		 (test_bit(vsi_handle, fm_entry->vsi_list_info->vsi_map))));
 }
 
@@ -2292,14 +2296,12 @@ ice_add_to_vsi_fltr_list(struct ice_hw *hw, u16 vsi_handle,
 		return ICE_ERR_PARAM;
 
 	list_for_each_entry(fm_entry, lkup_list_head, list_entry) {
-		struct ice_fltr_info *fi;
-
-		fi = &fm_entry->fltr_info;
-		if (!fi || !ice_vsi_uses_fltr(fm_entry, vsi_handle))
+		if (!ice_vsi_uses_fltr(fm_entry, vsi_handle))
 			continue;
 
 		status = ice_add_entry_to_vsi_fltr_list(hw, vsi_handle,
-							vsi_list_head, fi);
+							vsi_list_head,
+							&fm_entry->fltr_info);
 		if (status)
 			return status;
 	}
-- 
2.26.2


  parent reply	other threads:[~2021-03-29 20:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 20:18 [PATCH net 0/9][pull request] Intel Wired LAN Driver Updates 2021-03-29 Tony Nguyen
2021-03-29 20:18 ` [PATCH net 1/9] ice: Continue probe on link/PHY errors Tony Nguyen
2021-03-29 20:18 ` [PATCH net 2/9] ice: Increase control queue timeout Tony Nguyen
2021-03-29 20:18 ` [PATCH net 3/9] ice: Recognize 860 as iSCSI port in CEE mode Tony Nguyen
2021-03-29 20:18 ` [PATCH net 4/9] ice: prevent ice_open and ice_stop during reset Tony Nguyen
2021-03-29 20:18 ` [PATCH net 5/9] ice: fix memory allocation call Tony Nguyen
2021-03-29 20:18 ` [PATCH net 6/9] ice: remove DCBNL_DEVRESET bit from PF state Tony Nguyen
2021-03-29 20:18 ` Tony Nguyen [this message]
2021-03-29 20:18 ` [PATCH net 8/9] ice: Use port number instead of PF ID for WoL Tony Nguyen
2021-03-29 20:18 ` [PATCH net 9/9] ice: Cleanup fltr list in case of allocation issues Tony Nguyen
2021-03-29 23:40 ` [PATCH net 0/9][pull request] Intel Wired LAN Driver Updates 2021-03-29 patchwork-bot+netdevbpf

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=20210329201857.3509461-8-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=haiyue.wang@intel.com \
    --cc=jacekx.bulatek@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.com \
    --cc=tonyx.brelinski@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.