From 3be9c6db296825021bc4e85c6f0bde7df5543cc8 Mon Sep 17 00:00:00 2001 From: Wenzhuo Lu Date: Wed, 24 Apr 2019 10:43:42 +0800 Subject: [PATCH] net/ice: fix possible null pointer dereference 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, 328519, 328523 Fixes: e0dcf94a0d7f ("net/ice: support VLAN ops") Fixes: ff963bfa7cb1 ("net/ice: support RSS") Cc: stable@dpdk.org Signed-off-by: Wenzhuo Lu Acked-by: Qiming Yang Reviewed-by: Rami Rosen --- 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 1f06a2c807..429c2b6a14 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -645,12 +645,14 @@ ice_add_vlan_filter(struct ice_vsi *vsi, uint16_t vlan_id) 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 @@ ice_remove_vlan_filter(struct ice_vsi *vsi, uint16_t vlan_id) 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 @@ ice_remove_vlan_filter(struct ice_vsi *vsi, uint16_t vlan_id) 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) @@ -2565,13 +2569,16 @@ ice_get_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size) 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); -- 2.20.1