Skip to content

Commit

Permalink
net: dsa: Unregister slave_dev in error path
Browse files Browse the repository at this point in the history
With commit 0071f56 ("dsa: Register netdev before phy"), we are now trying
to free a network device that has been previously registered, and in case of
errors, this will make us hit the BUG_ON(dev->reg_state != NETREG_UNREGISTERED)
condition.

Fix this by adding a missing unregister_netdev() before free_netdev().

Fixes: 0071f56 ("dsa: Register netdev before phy")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Feb 18, 2016
1 parent 79be1a1 commit 73dcb55
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
ret = dsa_slave_phy_setup(p, slave_dev);
if (ret) {
netdev_err(master, "error %d setting up slave phy\n", ret);
unregister_netdev(slave_dev);
free_netdev(slave_dev);
return ret;
}
Expand Down

0 comments on commit 73dcb55

Please sign in to comment.