net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting
authorJisheng Zhang <Jisheng.Zhang@synaptics.com>
Fri, 3 Apr 2020 02:23:29 +0000 (10:23 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Apr 2020 22:58:54 +0000 (15:58 -0700)
Commit 9463c4455900 ("net: stmmac: dwmac1000: Clear unused address
entries") cleared the unused mac address entries, but introduced an
out-of bounds mac address register programming bug -- After setting
the secondary unicast mac addresses, the "reg" value has reached
netdev_uc_count() + 1, thus we should only clear address entries
if (addr < perfect_addr_number)

Fixes: 9463c4455900 ("net: stmmac: dwmac1000: Clear unused address entries")
Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c

index 542784300620ff41407c00fe7c6e948fc15cba32..efc6ec1b8027c63fd96ca13d9b0ab130c8c108c5 100644 (file)
@@ -207,7 +207,7 @@ static void dwmac1000_set_filter(struct mac_device_info *hw,
                        reg++;
                }
 
-               while (reg <= perfect_addr_number) {
+               while (reg < perfect_addr_number) {
                        writel(0, ioaddr + GMAC_ADDR_HIGH(reg));
                        writel(0, ioaddr + GMAC_ADDR_LOW(reg));
                        reg++;