]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mlxsw: fix refcount leak in mlxsw_sp_port_lag_join()
authorWentao Liang <vulab@iscas.ac.cn>
Tue, 9 Jun 2026 08:37:09 +0000 (08:37 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 11 Jun 2026 22:49:06 +0000 (15:49 -0700)
When mlxsw_sp_port_lag_index_get() fails, mlxsw_sp_port_lag_join()
returns an error without releasing the lag reference obtained by
the earlier mlxsw_sp_lag_get().  All other error paths in the
function jump to the cleanup label that ends with
mlxsw_sp_lag_put(), so this is a single missed release.

Fix the leak by replacing the bare 'return err' with a goto to the
existing error cleanup label, which will drop the reference safely.

Cc: stable@vger.kernel.org
Fixes: 0d65fc13042f ("mlxsw: spectrum: Implement LAG port join/leave")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260609083709.209743-1-vulab@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index 1aaa75b47fe31d23447dfe41a99a808e6f698761..82569162d2e5d0cd4d39412fd45199eab46f653f 100644 (file)
@@ -4360,7 +4360,7 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
        lag_id = lag->lag_id;
        err = mlxsw_sp_port_lag_index_get(mlxsw_sp, lag_id, &port_index);
        if (err)
-               return err;
+               goto err_lag_uppers_bridge_join;
 
        err = mlxsw_sp_lag_uppers_bridge_join(mlxsw_sp_port, lag_dev,
                                              extack);