Skip to contentSkip to conversation

ice: fix VF reference leak in ice_set_vf_trust()

PATCH In review Wentao Liang 3 participants 3 messages Sep 17 – Oct 12

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

PATCH 1/1 ice: fix VF reference leak in ice_set_vf_trust()

ice_get_vf_by_id() takes a reference on the VF, which the caller has to release with ice_put_vf(). The switchdev mode check now happens after the VF is looked up and returns -EOPNOTSUPP without dropping that reference, leaking it.

Use the existing out_put_vf label instead.

Fixes 83b49e7f63da ("ice: check if VF exists before mode check")
---
 drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -1
index 7e00e091756d..202224dba1a3 100644
@@ -1384,7 +1384,8 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)
 
 	if (ice_is_eswitch_mode_switchdev(pf)) {
 		dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in switchdev mode\n");
-		return -EOPNOTSUPP;
+		ret = -EOPNOTSUPP;
+		goto out_put_vf;
 	}
 
 	ret = ice_check_vf_ready_for_cfg(vf);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines

-----Original Message-----
From: Wentao Liang <[email protected]>
Sent: Thursday, September 17, 2026 1:11 PM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; intel-wired- [email protected]; [email protected]; [email protected]; [email protected]; Swiatkowski, Michal <[email protected]>; [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Wentao Liang <[email protected]>; [email protected]
Subject: [PATCH] ice: fix VF reference leak in ice_set_vf_trust()

ice_get_vf_by_id() takes a reference on the VF, which the caller has to release with ice_put_vf(). The switchdev mode check now happens after the VF is looked up and returns -EOPNOTSUPP without dropping that reference, leaking it.

Use the existing out_put_vf label instead.

Fixes 83b49e7f63da ("ice: check if VF exists before mode check")
---
 drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -1
index 7e00e091756d..202224dba1a3 100644
@@ -1384,7 +1384,8 @@ int ice_set_vf_trust(struct net_device *netdev,
 int vf_id, bool trusted)
 
 	if (ice_is_eswitch_mode_switchdev(pf)) {
 		dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in
 switchdev mode\n");
-		return -EOPNOTSUPP;
+		ret = -EOPNOTSUPP;
+		goto out_put_vf;
 	}
Quoted 3 lines

ret = ice_check_vf_ready_for_cfg(vf);
--
2.34.1

Tested-by
#2 lore raw
Quoted 59 lines

-----Original Message-----
From: Loktionov, Aleksandr <[email protected]>
Sent: Thursday, September 17, 2026 1:29 PM
To: Wentao Liang <[email protected]>; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; intel-wired- [email protected]; [email protected]; [email protected]; linux- [email protected]; Swiatkowski, Michal <[email protected]>; [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; [email protected]
Subject: RE: [PATCH] ice: fix VF reference leak in ice_set_vf_trust()

Quoted 33 lines

-----Original Message-----
From: Wentao Liang <[email protected]>
Sent: Thursday, September 17, 2026 1:11 PM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; intel-wired- [email protected]; [email protected]; [email protected]; [email protected]; Swiatkowski, Michal <[email protected]>; [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Wentao Liang <[email protected]>; [email protected]
Subject: [PATCH] ice: fix VF reference leak in ice_set_vf_trust()

ice_get_vf_by_id() takes a reference on the VF, which the caller has to release with ice_put_vf(). The switchdev mode check now happens after the VF is looked up and returns -EOPNOTSUPP without dropping that reference, leaking it.

Use the existing out_put_vf label instead.

Fixes 83b49e7f63da ("ice: check if VF exists before mode check")
---
 drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -0
index 7e00e091756d..202224dba1a3 100644

drivers/net/ethernet/intel/ice/ice_sriov.c int ice_set_vf_trust(struct net_device *netdev, · line 1387

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -0
@@ -1384,7 +1384,8 @@ int ice_set_vf_trust(struct net_device *netdev,
 int vf_id, bool trusted)
 
 	if (ice_is_eswitch_mode_switchdev(pf)) {
 		dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in

switchdev

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -1
 mode\n");
-		return -EOPNOTSUPP;
+		ret = -EOPNOTSUPP;
+		goto out_put_vf;
 	}
Quoted 5 lines
Quoted 3 lines

ret = ice_check_vf_ready_for_cfg(vf);
--
2.34.1