net: dsa: sja1105: call dsa_unregister_switch when allocating memory fails
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 24 May 2021 09:25:23 +0000 (12:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 07:00:38 +0000 (09:00 +0200)
commit83999bf40c78ec344b7c1066dc50f21ac2519bdf
tree07c0d335e3f270194931bcf143295f03423cafa1
parentdd8609f203448ca6d58ae71461208b3f6b0329b0
net: dsa: sja1105: call dsa_unregister_switch when allocating memory fails

commit dc596e3fe63f88e3d1e509f64e7f761cd4135538 upstream.

Unlike other drivers which pretty much end their .probe() execution with
dsa_register_switch(), the sja1105 does some extra stuff. When that
fails with -ENOMEM, the driver is quick to return that, forgetting to
call dsa_unregister_switch(). Not critical, but a bug nonetheless.

Fixes: 4d7525085a9b ("net: dsa: sja1105: offload the Credit-Based Shaper qdisc")
Fixes: a68578c20a96 ("net: dsa: Make deferred_xmit private to sja1105")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/sja1105/sja1105_main.c