[PATCH] ice: fix VF reference leak in ice_set_vf_trust()

Loktionov, Aleksandr aleksandr.loktionov at intel.com
Thu Sep 17 11:28:50 UTC 2026



> -----Original Message-----
> From: Wentao Liang <vulab at iscas.ac.cn>
> Sent: Thursday, September 17, 2026 1:11 PM
> To: andrew+netdev at lunn.ch
> Cc: Nguyen, Anthony L <anthony.l.nguyen at intel.com>;
> davem at davemloft.net; edumazet at google.com; intel-wired-
> lan at lists.osuosl.org; kalyan.kodamagula at intel.com; kuba at kernel.org;
> linux-kernel at vger.kernel.org; Swiatkowski, Michal
> <michal.swiatkowski at intel.com>; netdev at vger.kernel.org;
> pabeni at redhat.com; Kitszel, Przemyslaw <przemyslaw.kitszel at intel.com>;
> Wentao Liang <vulab at iscas.ac.cn>; stable at vger.kernel.org
> 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")
> Cc: stable at vger.kernel.org
> Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
> ---
>  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 7e00e091756d..202224dba1a3 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sriov.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
> @@ -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);
> --
> 2.34.1

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov at intel.com>


More information about the Intel-wired-lan mailing list