netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mscc: ocelot: Fix uninitialized error in ocelot_netdevice_event()
@ 2018-06-07 13:10 Geert Uytterhoeven
  2018-06-07 20:55 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2018-06-07 13:10 UTC (permalink / raw)
  To: Alexandre Belloni, David S . Miller, Andrew Lunn
  Cc: Arnd Bergmann, netdev, linux-kernel, Geert Uytterhoeven

With gcc-4.1.2:

    drivers/net/ethernet/mscc/ocelot.c: In function ‘ocelot_netdevice_event’:
    drivers/net/ethernet/mscc/ocelot.c:1129: warning: ‘ret’ may be used uninitialized in this function

If the list iterated over by netdev_for_each_lower_dev() is empty, ret
is never initialized, and converted into a notifier return value.

Fix this by preinitializing ret to zero.

Fixes: a556c76adc052c97 ("net: mscc: Add initial Ocelot switch support")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
This may be unlikely to happen, but given the notifier is called for any
(also non-ocelot) network device, better be safe than sorry.
---
 drivers/net/ethernet/mscc/ocelot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index c8c74aa548d96e00..fb2c8f8071e64d3b 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1126,7 +1126,7 @@ static int ocelot_netdevice_event(struct notifier_block *unused,
 {
 	struct netdev_notifier_changeupper_info *info = ptr;
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
-	int ret;
+	int ret = 0;
 
 	if (netif_is_lag_master(dev)) {
 		struct net_device *slave;
-- 
2.7.4

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

* Re: [PATCH] net: mscc: ocelot: Fix uninitialized error in ocelot_netdevice_event()
  2018-06-07 13:10 [PATCH] net: mscc: ocelot: Fix uninitialized error in ocelot_netdevice_event() Geert Uytterhoeven
@ 2018-06-07 20:55 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-06-07 20:55 UTC (permalink / raw)
  To: geert; +Cc: alexandre.belloni, andrew, arnd, netdev, linux-kernel

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Thu,  7 Jun 2018 15:10:30 +0200

> With gcc-4.1.2:
> 
>     drivers/net/ethernet/mscc/ocelot.c: In function ‘ocelot_netdevice_event’:
>     drivers/net/ethernet/mscc/ocelot.c:1129: warning: ‘ret’ may be used uninitialized in this function
> 
> If the list iterated over by netdev_for_each_lower_dev() is empty, ret
> is never initialized, and converted into a notifier return value.
> 
> Fix this by preinitializing ret to zero.
> 
> Fixes: a556c76adc052c97 ("net: mscc: Add initial Ocelot switch support")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> This may be unlikely to happen, but given the notifier is called for any
> (also non-ocelot) network device, better be safe than sorry.

Applied.

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

end of thread, other threads:[~2018-06-07 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-07 13:10 [PATCH] net: mscc: ocelot: Fix uninitialized error in ocelot_netdevice_event() Geert Uytterhoeven
2018-06-07 20:55 ` 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).