RE: [Intel-wired-lan] [PATCH net] ice: fix double free in ice_sf_eth_activate() error path
From: Loktionov, Aleksandr
Date: Fri Apr 10 2026 - 04:13:07 EST
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf
> Of Greg Kroah-Hartman
> Sent: Thursday, April 9, 2026 5:11 PM
> To: intel-wired-lan@xxxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx; Greg Kroah-Hartman
> <gregkh@xxxxxxxxxxxxxxxxxxx>; Nguyen, Anthony L
> <anthony.l.nguyen@xxxxxxxxx>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@xxxxxxxxx>; Andrew Lunn <andrew+netdev@xxxxxxx>;
> David S. Miller <davem@xxxxxxxxxxxxx>; Eric Dumazet
> <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni
> <pabeni@xxxxxxxxxx>; Piotr Raczynski <piotr.raczynski@xxxxxxxxx>; Jiri
> Pirko <jiri@xxxxxxxxxxx>; Simon Horman <horms@xxxxxxxxxx>; Michal
> Swiatkowski <michal.swiatkowski@xxxxxxxxxxxxxxx>; stable
> <stable@xxxxxxxxxx>
> Subject: [Intel-wired-lan] [PATCH net] ice: fix double free in
> ice_sf_eth_activate() error path
>
> When auxiliary_device_add() fails, the aux_dev_uninit label calls
> auxiliary_device_uninit() and falls through to sf_dev_free and
> xa_erase.
> The uninit invokes ice_sf_dev_release(), which already frees sf_dev
> via
> kfree() and erases the entry from ice_sf_aux_id. The fall-through
> then double-frees sf_dev and double-erases the id.
>
> This is reachable from userspace via the devlink port function state-
> set netlink command.
>
> Fix this by returning right after uninit because the release callback
> handles all cleanup correctly.
>
> Cc: Tony Nguyen <anthony.l.nguyen@xxxxxxxxx>
> Cc: Przemek Kitszel <przemyslaw.kitszel@xxxxxxxxx>
> Cc: Andrew Lunn <andrew+netdev@xxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: Piotr Raczynski <piotr.raczynski@xxxxxxxxx>
> Cc: Jiri Pirko <jiri@xxxxxxxxxxx>
> Cc: Simon Horman <horms@xxxxxxxxxx>
> Cc: Michal Swiatkowski <michal.swiatkowski@xxxxxxxxxxxxxxx>
> Fixes: 177ef7f1e2a0 ("ice: base subfunction aux driver")
> Cc: stable <stable@xxxxxxxxxx>
> Assisted-by: gregkh_clanker_t1000
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/net/ethernet/intel/ice/ice_sf_eth.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> index 2cf04bc6edce..6bc8aa896762 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> @@ -304,7 +304,9 @@ ice_sf_eth_activate(struct ice_dynamic_port
> *dyn_port,
> return 0;
>
> aux_dev_uninit:
> + /* ice_sf_dev_release() frees sf_dev and erases the xa entry */
> auxiliary_device_uninit(&sf_dev->adev);
> + return err;
> sf_dev_free:
> kfree(sf_dev);
> xa_erase:
> --
> 2.53.0
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@xxxxxxxxx>