Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3eb8feeb authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller
Browse files

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: 71e0bbde ("net: dsa: Add support for platform data")
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 829385f0
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -496,13 +496,14 @@ 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]);
		dev_put(ethernet_dev);
	}

		if (!ethernet_dev)
			return -EPROBE_DEFER;
		dev_put(ethernet_dev);
	}

	if (!dst->cpu_dp) {
		dst->cpu_dp = port;