diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-10-24 16:37:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-25 10:49:14 +0900 |
commit | 3eb8feeb1708c7dbfd2e97df92a2a407c116606e (patch) | |
tree | 0c922fe5e47208525173a35c91f2743385df3780 /net/dsa | |
parent | 829385f08ae99740276cbd46c9db29764c519211 (diff) | |
download | linux-3eb8feeb1708c7dbfd2e97df92a2a407c116606e.tar.bz2 |
net: dsa: check master device before put
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>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa2.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 873af0108e24..045d8a176279 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -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; |