staging: most: fix race condition in AIM networking
authorChristian Gromm <christian.gromm@microchip.com>
Mon, 28 Sep 2015 15:18:32 +0000 (17:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 01:18:49 +0000 (03:18 +0200)
If the network device is being opened right after it has been registered
via function register_netdev(), the device state is not yet consistent in
the context of function ndo_open(). This patch cares about having the
initialization done right, before the networking device is registered.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/aim-network/networking.c

index dd368721b7277e34e9c6f61fd58dc6200465c484..761c4cbff3e1b2dd0c20fb00ec914bd7aa4291d2 100644 (file)
@@ -356,10 +356,13 @@ static int aim_probe_channel(struct most_interface *iface, int channel_idx,
                }
 
                nd->dev = dev;
+               ch->ch_id = channel_idx;
+               ch->linked = true;
 
                dev->ml_priv = nd;
                if (register_netdev(dev)) {
                        pr_err("registering net device failed\n");
+                       ch->linked = false;
                        free_netdev(dev);
                        return -EINVAL;
                }