Skip to content

Commit 35dfedc

Browse files
Ovidiu Panaitkuba-moo
authored andcommitted
net: stmmac: Fix error handling in VLAN add and delete paths
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>
1 parent 550921c commit 35dfedc

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
@@ -6794,9 +6794,13 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid
67946794

67956795
if (priv->hw->num_vlan) {
67966796
ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
6797-
if (ret)
6797+
if (ret) {
6798+
clear_bit(vid, priv->active_vlans);
6799+
stmmac_vlan_update(priv, is_double);
67986800
goto err_pm_put;
6801+
}
67996802
}
6803+
68006804
err_pm_put:
68016805
pm_runtime_put(priv->device);
68026806

@@ -6820,15 +6824,21 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi
68206824
is_double = true;
68216825

68226826
clear_bit(vid, priv->active_vlans);
6827+
ret = stmmac_vlan_update(priv, is_double);
6828+
if (ret) {
6829+
set_bit(vid, priv->active_vlans);
6830+
goto del_vlan_error;
6831+
}
68236832

68246833
if (priv->hw->num_vlan) {
68256834
ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
6826-
if (ret)
6835+
if (ret) {
6836+
set_bit(vid, priv->active_vlans);
6837+
stmmac_vlan_update(priv, is_double);
68276838
goto del_vlan_error;
6839+
}
68286840
}
68296841

6830-
ret = stmmac_vlan_update(priv, is_double);
6831-
68326842
del_vlan_error:
68336843
pm_runtime_put(priv->device);
68346844

0 commit comments

Comments
 (0)