提交 ba3d0dda 编写于 作者: A Arnd Bergmann 提交者: David S. Miller

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: NArnd Bergmann <arnd@arndb.de>
Fixes: 03377e38 ("drivers: net: xgene: Fix backward compatibility")
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 53700f0c
...@@ -761,10 +761,6 @@ int xgene_enet_phy_connect(struct net_device *ndev) ...@@ -761,10 +761,6 @@ int xgene_enet_phy_connect(struct net_device *ndev)
if (dev->of_node) { if (dev->of_node) {
for (i = 0 ; i < 2; i++) { for (i = 0 ; i < 2; i++) {
np = of_parse_phandle(dev->of_node, "phy-handle", i); np = of_parse_phandle(dev->of_node, "phy-handle", i);
if (!np)
continue;
phy_dev = of_phy_connect(ndev, np, phy_dev = of_phy_connect(ndev, np,
&xgene_enet_adjust_link, &xgene_enet_adjust_link,
0, pdata->phy_mode); 0, pdata->phy_mode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册