Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: xgene: fix backward compatibility fix

A bugfix for backward compatibility handling introduced undefined
behavior for the case that of_parse_phandle() does not return
a valid entry, as "gcc -Wmaybe-unused" reports:

drivers/net/ethernet/apm/xgene/xgene_enet_hw.c: In function 'xgene_enet_phy_connect':
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c:776:6: error: 'phy_dev' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c: In function 'xgene_enet_mdio_config':
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c:776:6: error: 'phy_dev' may be used uninitialized in this function [-Werror=maybe-uninitialized]

We can work around this by removing the check for zero "np", as
of_phy_connect() will correctly handle a NULL argument so we fall
back into the normal error handling case.

Note that I had previously fixed another bug that resulted in the
exact same warning, but this is a different problem that was
introduced after my original fix.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 03377e381bf4 ("drivers: net: xgene: Fix backward compatibility")
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnd Bergmann and committed by
David S. Miller
ba3d0dda 53700f0c

-4
-4
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
··· 761 761 if (dev->of_node) { 762 762 for (i = 0 ; i < 2; i++) { 763 763 np = of_parse_phandle(dev->of_node, "phy-handle", i); 764 - 765 - if (!np) 766 - continue; 767 - 768 764 phy_dev = of_phy_connect(ndev, np, 769 765 &xgene_enet_adjust_link, 770 766 0, pdata->phy_mode);