[PATCH] ice: release the VF reference in the switchdev trust path

From: Wentao Liang

Date: Tue Nov 03 2026 - 05:17:44 EST


ice_set_vf_trust() takes a reference on the VF with ice_get_vf_by_id()
and then rejects the request when the PF is in switchdev mode without
dropping that reference.

Return through the existing out_put_vf label so the VF reference is
released on this path too.

Fixes: 1281b7459657 ("ice: Forbid trusted VFs in switchdev mode")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index c49f48b5ae38..90bf1becbc3d 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -1400,7 +1400,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);
--
2.34.1