Skip to content

Commit 4ab6023

Browse files
Ovidiu PanaitSasha Levin
authored andcommitted
net: stmmac: Fix error handling in VLAN add and delete paths
[ Upstream commit 35dfedc ] stmmac_vlan_rx_add_vid() updates active_vlans and the VLAN hash register before writing the HW filter entry. If the filter write fails, it leaves a stale VID in active_vlans and the hash register. stmmac_vlan_rx_kill_vid() has the reverse problem: it clears active_vlans before removing the HW filter. On failure, the VID is gone from active_vlans but still present in the HW filter table. To fix this, reorder the operations to update the hash table first, then attempt the HW filter operation. If the HW filter fails, roll back both the active_vlans bitmap and the hash table by calling stmmac_vlan_update() again. Fixes: ed64639 ("net: stmmac: Add support for VLAN Rx filtering") Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com> Link: https://patch.msgid.link/20260303145828.7845-2-ovidiu.panait.rb@renesas.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent da4515f commit 4ab6023

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6746,9 +6746,13 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid
67466746

67476747
if (priv->hw->num_vlan) {
67486748
ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
6749-
if (ret)
6749+
if (ret) {
6750+
clear_bit(vid, priv->active_vlans);
6751+
stmmac_vlan_update(priv, is_double);
67506752
goto err_pm_put;
6753+
}
67516754
}
6755+
67526756
err_pm_put:
67536757
pm_runtime_put(priv->device);
67546758

@@ -6772,15 +6776,21 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi
67726776
is_double = true;
67736777

67746778
clear_bit(vid, priv->active_vlans);
6779+
ret = stmmac_vlan_update(priv, is_double);
6780+
if (ret) {
6781+
set_bit(vid, priv->active_vlans);
6782+
goto del_vlan_error;
6783+
}
67756784

67766785
if (priv->hw->num_vlan) {
67776786
ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
6778-
if (ret)
6787+
if (ret) {
6788+
set_bit(vid, priv->active_vlans);
6789+
stmmac_vlan_update(priv, is_double);
67796790
goto del_vlan_error;
6791+
}
67806792
}
67816793

6782-
ret = stmmac_vlan_update(priv, is_double);
6783-
67846794
del_vlan_error:
67856795
pm_runtime_put(priv->device);
67866796

0 commit comments

Comments
 (0)