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: 71e0bbde0d
("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>
This commit is contained in:
parent
829385f08a
commit
3eb8feeb17
|
@ -496,14 +496,15 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
|
||||||
if (!ethernet)
|
if (!ethernet)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
ethernet_dev = of_find_net_device_by_node(ethernet);
|
ethernet_dev = of_find_net_device_by_node(ethernet);
|
||||||
|
if (!ethernet_dev)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
} else {
|
} else {
|
||||||
ethernet_dev = dsa_dev_to_net_device(ds->cd->netdev[index]);
|
ethernet_dev = dsa_dev_to_net_device(ds->cd->netdev[index]);
|
||||||
|
if (!ethernet_dev)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
dev_put(ethernet_dev);
|
dev_put(ethernet_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ethernet_dev)
|
|
||||||
return -EPROBE_DEFER;
|
|
||||||
|
|
||||||
if (!dst->cpu_dp) {
|
if (!dst->cpu_dp) {
|
||||||
dst->cpu_dp = port;
|
dst->cpu_dp = port;
|
||||||
dst->cpu_dp->netdev = ethernet_dev;
|
dst->cpu_dp->netdev = ethernet_dev;
|
||||||
|
|
Loading…
Reference in New Issue