Skip to content

Commit

Permalink
net: dsa: check master device before put
Browse files Browse the repository at this point in the history
In the case of pdata, the dsa_cpu_parse function calls dev_put() before
making sure it isn't NULL. Fix this.

Fixes: 71e0bbd ("net: dsa: Add support for platform data")
Signed-off-by: Vivien Didelot <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vivien authored and davem330 committed Oct 25, 2017
1 parent 829385f commit 3eb8fee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/dsa/dsa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3eb8fee

Please sign in to comment.