]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: check master device before put
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Tue, 24 Oct 2017 20:37:19 +0000 (16:37 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Oct 2017 01:49:14 +0000 (10:49 +0900)
In the case of pdata, the dsa_cpu_parse function calls dev_put() before
making sure it isn't NULL. Fix this.

Fixes: 71e0bbde0d88 ("net: dsa: Add support for platform data")
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa2.c

index 873af0108e243fc269f591ec7d7c59a9c8b374fc..045d8a1762793142de2619497da3034f0af55e0c 100644 (file)
@@ -496,14 +496,15 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
                if (!ethernet)
                        return -EINVAL;
                ethernet_dev = of_find_net_device_by_node(ethernet);
+               if (!ethernet_dev)
+                       return -EPROBE_DEFER;
        } else {
                ethernet_dev = dsa_dev_to_net_device(ds->cd->netdev[index]);
+               if (!ethernet_dev)
+                       return -EPROBE_DEFER;
                dev_put(ethernet_dev);
        }
 
-       if (!ethernet_dev)
-               return -EPROBE_DEFER;
-
        if (!dst->cpu_dp) {
                dst->cpu_dp = port;
                dst->cpu_dp->netdev = ethernet_dev;