diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-02-08 02:10:13 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-18 09:11:43 -0500 |
commit | 12758a282435c0ab4878ef163e82420a8e250b73 (patch) | |
tree | 0cb841e6278714a33dc8a150a0ece389255d0009 /net/dsa/dsa2.c | |
parent | a700cf26a3be881e32573cb0e6373278fac2348a (diff) |
net: dsa: Do not destroy invalid network devices
[ Upstream commit 382e1eea2d983cd2343482c6a638f497bb44a636 ]
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: 83c0afaec7b7 ("net: dsa: Add new binding implementation")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/dsa/dsa2.c')
-rw-r--r-- | net/dsa/dsa2.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index da3862124545..0f99297b2fb3 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c | |||
@@ -273,6 +273,7 @@ static int dsa_user_port_apply(struct device_node *port, u32 index, | |||
273 | if (err) { | 273 | if (err) { |
274 | dev_warn(ds->dev, "Failed to create slave %d: %d\n", | 274 | dev_warn(ds->dev, "Failed to create slave %d: %d\n", |
275 | index, err); | 275 | index, err); |
276 | ds->ports[index].netdev = NULL; | ||
276 | return err; | 277 | return err; |
277 | } | 278 | } |
278 | 279 | ||