]> git.baikalelectronics.ru Git - kernel.git/commit
nixge: fix mac address error handling again
authorArnd Bergmann <arnd@arndb.de>
Mon, 22 Nov 2021 15:02:49 +0000 (16:02 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Nov 2021 15:05:48 +0000 (15:05 +0000)
commit38b49450264492fac67968f1d118dc6e04e7f486
tree25f99de5d815df07e5b5d555d4172ded69698672
parent6dd88f408b459f9a1216a228f21cc61ba7bb5ab4
nixge: fix mac address error handling again

The change to eth_hw_addr_set() caused gcc to correctly spot a
bug that was introduced in an earlier incorrect fix:

In file included from include/linux/etherdevice.h:21,
                 from drivers/net/ethernet/ni/nixge.c:7:
In function '__dev_addr_set',
    inlined from 'eth_hw_addr_set' at include/linux/etherdevice.h:319:2,
    inlined from 'nixge_probe' at drivers/net/ethernet/ni/nixge.c:1286:3:
include/linux/netdevice.h:4648:9: error: 'memcpy' reading 6 bytes from a region of size 0 [-Werror=stringop-overread]
 4648 |         memcpy(dev->dev_addr, addr, len);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As nixge_get_nvmem_address() can return either NULL or an error
pointer, the NULL check is wrong, and we can end up reading from
ERR_PTR(-EOPNOTSUPP), which gcc knows to contain zero readable
bytes.

Make the function always return an error pointer again but fix
the check to match that.

Fixes: 29eb90efca1a ("ethernet: use eth_hw_addr_set() instead of ether_addr_copy()")
Fixes: 542b9441b639 ("net: nixge: Fix error path for obtaining mac address")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ni/nixge.c