linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: xgene: fix backward compatibility fix
@ 2016-08-29 12:37 Arnd Bergmann
  2016-09-01 17:01 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-08-29 12:37 UTC (permalink / raw)
  To: Iyappan Subramanian, Keyur Chudgar
  Cc: Arnd Bergmann, David S. Miller, netdev, linux-kernel

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")
---
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 321fb197621e..da413c8d3e19 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -761,10 +761,6 @@ int xgene_enet_phy_connect(struct net_device *ndev)
 	if (dev->of_node) {
 		for (i = 0 ; i < 2; i++) {
 			np = of_parse_phandle(dev->of_node, "phy-handle", i);
-
-			if (!np)
-				continue;
-
 			phy_dev = of_phy_connect(ndev, np,
 						 &xgene_enet_adjust_link,
 						 0, pdata->phy_mode);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: xgene: fix backward compatibility fix
  2016-08-29 12:37 [PATCH] net: xgene: fix backward compatibility fix Arnd Bergmann
@ 2016-09-01 17:01 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-09-01 17:01 UTC (permalink / raw)
  To: arnd; +Cc: isubramanian, kchudgar, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 29 Aug 2016 14:37:14 +0200

> 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")

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-01 21:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-29 12:37 [PATCH] net: xgene: fix backward compatibility fix Arnd Bergmann
2016-09-01 17:01 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).