Skip to content

Commit

Permalink
net: dsa: Do not destroy invalid network devices
Browse files Browse the repository at this point in the history
dsa_slave_create() can fail, and dsa_user_port_unapply() will properly check
for the network device not being NULL before attempting to destroy it. We were
not setting the slave network device as NULL if dsa_slave_create() failed, so
we would later on be calling dsa_slave_destroy() on a now free'd and
unitialized network device, causing crashes in dsa_slave_destroy().

Fixes: 83c0afa ("net: dsa: Add new binding implementation")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
ffainelli authored and davem330 committed Feb 8, 2017
1 parent 73d2c66 commit 382e1ee
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/dsa/dsa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ static int dsa_user_port_apply(struct device_node *port, u32 index,
if (err) {
dev_warn(ds->dev, "Failed to create slave %d: %d\n",
index, err);
ds->ports[index].netdev = NULL;
return err;
}

Expand Down

0 comments on commit 382e1ee

Please sign in to comment.