Skip to content

Commit

Permalink
mlxsw: spectrum_switchdev: Avoid leaking FID's reference count
Browse files Browse the repository at this point in the history
It should never be possible for a user to set a VNI on a FID in case one
is already set. The driver therefore returns an error, but fails to drop
the reference count taken earlier when calling
mlxsw_sp_fid_8021d_lookup().

Drop the reference when this unlikely error is hit.

Fixes: 1c30d18 ("mlxsw: spectrum: Enable VxLAN enslavement to bridges")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ido Schimmel authored and David S. Miller committed Dec 6, 2018
1 parent 050fc01 commit f58a83c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2134,8 +2134,10 @@ mlxsw_sp_bridge_8021d_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device,
if (!fid)
return -EINVAL;

if (mlxsw_sp_fid_vni_is_set(fid))
return -EINVAL;
if (mlxsw_sp_fid_vni_is_set(fid)) {
err = -EINVAL;
goto err_vni_exists;
}

err = mlxsw_sp_nve_fid_enable(mlxsw_sp, fid, &params, extack);
if (err)
Expand All @@ -2149,6 +2151,7 @@ mlxsw_sp_bridge_8021d_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device,
return 0;

err_nve_fid_enable:
err_vni_exists:
mlxsw_sp_fid_put(fid);
return err;
}
Expand Down

0 comments on commit f58a83c

Please sign in to comment.