Commit dd6a4998e64a7806b54c3eba1e5e7bf6c81ccf8c

Authored by Jose Abreu
Committed by David S. Miller
1 parent cc213f8c47

net: stmmac: Fix VLAN filtering when HW does not support it

If we don't have any filters available we can't rely upon the return
code of stmmac_add_hw_vlan_rx_fltr() / stmmac_del_hw_vlan_rx_fltr(). Add
a check for this.

Fixes: ed64639bc1e0 ("net: stmmac: Add support for VLAN Rx filtering")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 12 additions and 5 deletions Side-by-side Diff

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
... ... @@ -4566,9 +4566,13 @@
4566 4566 return ret;
4567 4567 }
4568 4568  
4569   - ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
  4569 + if (priv->hw->num_vlan) {
  4570 + ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
  4571 + if (ret)
  4572 + return ret;
  4573 + }
4570 4574  
4571   - return ret;
  4575 + return 0;
4572 4576 }
4573 4577  
4574 4578 static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
... ... @@ -4581,9 +4585,12 @@
4581 4585 is_double = true;
4582 4586  
4583 4587 clear_bit(vid, priv->active_vlans);
4584   - ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
4585   - if (ret)
4586   - return ret;
  4588 +
  4589 + if (priv->hw->num_vlan) {
  4590 + ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
  4591 + if (ret)
  4592 + return ret;
  4593 + }
4587 4594  
4588 4595 return stmmac_vlan_update(priv, is_double);
4589 4596 }