Skip to contentSkip to conversation

ice: Check VF VSI Pointer Value in ice_vc_add_fdir_fltr()

PATCH In review Xuanqiang Luo 3 participants 6 messages Mar 25, 2025 – Apr 8, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ice: Check VF VSI Pointer Value in ice_vc_add_fdir_fltr()

From: Xuanqiang Luo <[email protected]>

As mentioned in the commit baeb705fd6a7 ("ice: always check VF VSI pointer values"), we need to perform a null pointer check on the return value of ice_get_vf_vsi() before using it.

v2: Add "iwl-net" to the subject and modify the name format.

Fixes 6ebbe97a4881 ("ice: Add a per-VF limit on number of FDIR filters")
---
 drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
index 14e3f0f89c78..53bad68e3f38 100644
@@ -2092,6 +2092,12 @@ int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg)
 	dev = ice_pf_to_dev(pf);
 	vf_vsi = ice_get_vf_vsi(vf);
 
+	if (!vf_vsi) {
+		dev_err(dev, "Can not get FDIR vf_vsi for VF %u\n", vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto err_exit;
+	}
+
 #define ICE_VF_MAX_FDIR_FILTERS	128
 	if (!ice_fdir_num_avail_fltr(&pf->hw, vf_vsi) ||
 	    vf->fdir.fdir_fltr_cnt_total >= ICE_VF_MAX_FDIR_FILTERS) {
Signature · 1 line
2.27.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Xuanqiang Luo

From: Xuanqiang Luo <[email protected]>

As mentioned in the commit baeb705fd6a7 ("ice: always check VF VSI pointer values"), we need to perform a null pointer check on the return value of ice_get_vf_vsi() before using it.

v2: Add "iwl-net" to the subject and modify the name format.

Fixes 6ebbe97a4881 ("ice: Add a per-VF limit on number of FDIR filters")

---

(technically the changelog (v2:...) should be placed here, with additional "---" line afterwards; no need to resubmit just for that)

Quoted 20 lines
  drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
index 14e3f0f89c78..53bad68e3f38 100644
@@ -2092,6 +2092,12 @@ int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg)
  	dev = ice_pf_to_dev(pf);
  	vf_vsi = ice_get_vf_vsi(vf);
 
+	if (!vf_vsi) {
+		dev_err(dev, "Can not get FDIR vf_vsi for VF %u\n", vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto err_exit;
+	}
+
  #define ICE_VF_MAX_FDIR_FILTERS	128
  	if (!ice_fdir_num_avail_fltr(&pf->hw, vf_vsi) ||
  	    vf->fdir.fdir_fltr_cnt_total >= ICE_VF_MAX_FDIR_FILTERS) {
#2 lore raw
Quoted 9 lines · Przemek Kitszel
Quoted 8 lines · Xuanqiang Luo

From: Xuanqiang Luo <[email protected]>

As mentioned in the commit baeb705fd6a7 ("ice: always check VF VSI pointer values"), we need to perform a null pointer check on the return value of ice_get_vf_vsi() before using it.

v2: Add "iwl-net" to the subject and modify the name format.

Quoted 8 lines
Quoted 3 lines
Fixes 6ebbe97a4881 ("ice: Add a per-VF limit on number of FDIR filters")

---

(technically the changelog (v2:...) should be placed here, with additional "---" line afterwards; no need to resubmit just for that)

Thank you for your guidance. I'll keep this in mind. :) BRs! Xuanqiang

Quoted 20 lines
Quoted 20 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 6 ++++++

  1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +5 -0
index 14e3f0f89c78..53bad68e3f38 100644
@@ -2092,6 +2092,12 @@ int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 
 *msg)
       dev = ice_pf_to_dev(pf);
       vf_vsi = ice_get_vf_vsi(vf);
   +    if (!vf_vsi) {
+        dev_err(dev, "Can not get FDIR vf_vsi for VF %u\n", vf->vf_id);
+        v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+        goto err_exit;
+    }
+
   #define ICE_VF_MAX_FDIR_FILTERS    128

      if (!ice_fdir_num_avail_fltr(&pf->hw, vf_vsi) || vf->fdir.fdir_fltr_cnt_total >= ICE_VF_MAX_FDIR_FILTERS) {

reviewer Reviewed-by on v2 1/1
#3 lore raw
In reply to Xuanqiang Luo
Quoted 10 lines · Xuanqiang Luo

From: Xuanqiang Luo <[email protected]>

As mentioned in the commit baeb705fd6a7 ("ice: always check VF VSI pointer values"), we need to perform a null pointer check on the return value of ice_get_vf_vsi() before using it.

v2: Add "iwl-net" to the subject and modify the name format.

Fixes 6ebbe97a4881 ("ice: Add a per-VF limit on number of FDIR filters")

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg) · line 2094

Quoted 12 lines
---
 drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
index 14e3f0f89c78..53bad68e3f38 100644
@@ -2092,6 +2092,12 @@ int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg)
 	dev = ice_pf_to_dev(pf);
 	vf_vsi = ice_get_vf_vsi(vf);
 

nit, but not need to repost because of this: it's seems nicer not to have not to have a blank line here. And instead, if one is really wanted, put it above the ice_get_vf_vsi() line.

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+	if (!vf_vsi) {
+		dev_err(dev, "Can not get FDIR vf_vsi for VF %u\n", vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto err_exit;
+	}
+
 #define ICE_VF_MAX_FDIR_FILTERS	128
 	if (!ice_fdir_num_avail_fltr(&pf->hw, vf_vsi) ||
 	    vf->fdir.fdir_fltr_cnt_total >= ICE_VF_MAX_FDIR_FILTERS) {
Signature · 1 line
2.27.0
#4 lore raw
Quoted 17 lines · Simon Horman
Quoted 10 lines · Xuanqiang Luo

From: Xuanqiang Luo <[email protected]>

As mentioned in the commit baeb705fd6a7 ("ice: always check VF VSI pointer values"), we need to perform a null pointer check on the return value of ice_get_vf_vsi() before using it.

v2: Add "iwl-net" to the subject and modify the name format.

Fixes 6ebbe97a4881 ("ice: Add a per-VF limit on number of FDIR filters")
Quoted 4 lines
---
  drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 6 ++++++
  1 file changed, 6 insertions(+)
Quoted 12 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg) · line 2094

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
index 14e3f0f89c78..53bad68e3f38 100644
@@ -2092,6 +2092,12 @@ int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg)
  	dev = ice_pf_to_dev(pf);
  	vf_vsi = ice_get_vf_vsi(vf);
 

nit, but not need to repost because of this: it's seems nicer not to have not to have a blank line here. And instead, if one is really wanted, put it above the ice_get_vf_vsi() line.

Thank you for the reminder. I will take this into consideration when submitting other patches next time. Since vf_vsi and its judgment logic are logically adjacent, it's better not to separate them with blank lines.

Quoted 13 lines
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+	if (!vf_vsi) {
+		dev_err(dev, "Can not get FDIR vf_vsi for VF %u\n", vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto err_exit;
+	}
+
  #define ICE_VF_MAX_FDIR_FILTERS	128
  	if (!ice_fdir_num_avail_fltr(&pf->hw, vf_vsi) ||
  	    vf->fdir.fdir_fltr_cnt_total >= ICE_VF_MAX_FDIR_FILTERS) {
Signature · 1 line
2.27.0
reviewer
#5 lore raw
Quoted 30 lines · luoxuanqiang
Quoted 17 lines · Simon Horman
Quoted 10 lines · Xuanqiang Luo

From: Xuanqiang Luo <[email protected]>

As mentioned in the commit baeb705fd6a7 ("ice: always check VF VSI pointer values"), we need to perform a null pointer check on the return value of ice_get_vf_vsi() before using it.

v2: Add "iwl-net" to the subject and modify the name format.

Fixes 6ebbe97a4881 ("ice: Add a per-VF limit on number of FDIR filters")
Quoted 4 lines
---
  drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 6 ++++++
  1 file changed, 6 insertions(+)
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg) · line 2093

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
index 14e3f0f89c78..53bad68e3f38 100644
@@ -2092,6 +2092,12 @@ int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg)
  	dev = ice_pf_to_dev(pf);
  	vf_vsi = ice_get_vf_vsi(vf);

nit, but not need to repost because of this: it's seems nicer not to have not to have a blank line here. And instead, if one is really wanted, put it above the ice_get_vf_vsi() line.

Quoted 4 lines

Thank you for the reminder. I will take this into consideration when submitting other patches next time. Since vf_vsi and its judgment logic are logically adjacent, it's better not to separate them with blank lines.

Yes, agreed. Thanks.