linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mdio: mux: avoid 'maybe-uninitialized' warning
@ 2016-06-14 10:03 Arnd Bergmann
  2016-06-14 20:45 ` Andrew Lunn
  2016-06-16  3:49 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-06-14 10:03 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Arnd Bergmann, David S. Miller, Andrew Lunn, Pramod Kumar,
	netdev, linux-kernel

The latest changes to the MDIO code introduced a false-positive
warning with gcc-6 (possibly others):

drivers/net/phy/mdio-mux.c: In function 'mdio_mux_init':
drivers/net/phy/mdio-mux.c:188:3: error: 'parent_bus_node' may be used uninitialized in this function [-Werror=maybe-uninitialized]

It's easy to avoid the warning by making sure the parent_bus_node
is initialized in both cases at the start of the function, since
the later 'of_node_put()' call is also valid for a NULL pointer
argument.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: f20e6657a875 ("mdio: mux: Enhanced MDIO mux framework for integrated multiplexers")
---
 drivers/net/phy/mdio-mux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index dbd4ecc205dc..963838d4fac1 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -115,6 +115,7 @@ int mdio_mux_init(struct device *dev,
 			goto err_parent_bus;
 		}
 	} else {
+		parent_bus_node = NULL;
 		parent_bus = mux_bus;
 	}
 
@@ -184,8 +185,7 @@ int mdio_mux_init(struct device *dev,
 	put_device(&pb->mii_bus->dev);
 
 err_parent_bus:
-	if (!mux_bus)
-		of_node_put(parent_bus_node);
+	of_node_put(parent_bus_node);
 	return ret_val;
 }
 EXPORT_SYMBOL_GPL(mdio_mux_init);
-- 
2.7.0

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

* Re: [PATCH] mdio: mux: avoid 'maybe-uninitialized' warning
  2016-06-14 10:03 [PATCH] mdio: mux: avoid 'maybe-uninitialized' warning Arnd Bergmann
@ 2016-06-14 20:45 ` Andrew Lunn
  2016-06-16  3:49 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2016-06-14 20:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Florian Fainelli, David S. Miller, Pramod Kumar, netdev, linux-kernel

On Tue, Jun 14, 2016 at 12:03:17PM +0200, Arnd Bergmann wrote:
> The latest changes to the MDIO code introduced a false-positive
> warning with gcc-6 (possibly others):
> 
> drivers/net/phy/mdio-mux.c: In function 'mdio_mux_init':
> drivers/net/phy/mdio-mux.c:188:3: error: 'parent_bus_node' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> It's easy to avoid the warning by making sure the parent_bus_node
> is initialized in both cases at the start of the function, since
> the later 'of_node_put()' call is also valid for a NULL pointer
> argument.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: f20e6657a875 ("mdio: mux: Enhanced MDIO mux framework for integrated multiplexers")

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks Arnd

    Andrew

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

* Re: [PATCH] mdio: mux: avoid 'maybe-uninitialized' warning
  2016-06-14 10:03 [PATCH] mdio: mux: avoid 'maybe-uninitialized' warning Arnd Bergmann
  2016-06-14 20:45 ` Andrew Lunn
@ 2016-06-16  3:49 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-06-16  3:49 UTC (permalink / raw)
  To: arnd; +Cc: f.fainelli, andrew, pramod.kumar, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 14 Jun 2016 12:03:17 +0200

> The latest changes to the MDIO code introduced a false-positive
> warning with gcc-6 (possibly others):
> 
> drivers/net/phy/mdio-mux.c: In function 'mdio_mux_init':
> drivers/net/phy/mdio-mux.c:188:3: error: 'parent_bus_node' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> It's easy to avoid the warning by making sure the parent_bus_node
> is initialized in both cases at the start of the function, since
> the later 'of_node_put()' call is also valid for a NULL pointer
> argument.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: f20e6657a875 ("mdio: mux: Enhanced MDIO mux framework for integrated multiplexers")

Applied.

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

end of thread, other threads:[~2016-06-16  3:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 10:03 [PATCH] mdio: mux: avoid 'maybe-uninitialized' warning Arnd Bergmann
2016-06-14 20:45 ` Andrew Lunn
2016-06-16  3:49 ` 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).