]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: mscc: ocelot: Fix uninitialized error in ocelot_netdevice_event()
authorGeert Uytterhoeven <geert@linux-m68k.org>
Thu, 7 Jun 2018 13:10:30 +0000 (15:10 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 Jun 2018 20:54:39 +0000 (16:54 -0400)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c

index c8c74aa548d96e00bbad834b943bf2365df7bdad..fb2c8f8071e64d3b6d52865ecaddf17f841a2b9d 100644 (file)
@@ -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;