Commit dc596e3f authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: sja1105: call dsa_unregister_switch when allocating memory fails

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: 4d752508 ("net: dsa: sja1105: offload the Credit-Based Shaper qdisc")
Fixes: a68578c2 ("net: dsa: Make deferred_xmit private to sja1105")
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ba61cf16
...@@ -3646,8 +3646,10 @@ static int sja1105_probe(struct spi_device *spi) ...@@ -3646,8 +3646,10 @@ static int sja1105_probe(struct spi_device *spi)
priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers, priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers,
sizeof(struct sja1105_cbs_entry), sizeof(struct sja1105_cbs_entry),
GFP_KERNEL); GFP_KERNEL);
if (!priv->cbs) if (!priv->cbs) {
return -ENOMEM; rc = -ENOMEM;
goto out_unregister_switch;
}
} }
/* Connections between dsa_port and sja1105_port */ /* Connections between dsa_port and sja1105_port */
...@@ -3672,7 +3674,7 @@ static int sja1105_probe(struct spi_device *spi) ...@@ -3672,7 +3674,7 @@ static int sja1105_probe(struct spi_device *spi)
dev_err(ds->dev, dev_err(ds->dev,
"failed to create deferred xmit thread: %d\n", "failed to create deferred xmit thread: %d\n",
rc); rc);
goto out; goto out_destroy_workers;
} }
skb_queue_head_init(&sp->xmit_queue); skb_queue_head_init(&sp->xmit_queue);
sp->xmit_tpid = ETH_P_SJA1105; sp->xmit_tpid = ETH_P_SJA1105;
...@@ -3682,7 +3684,8 @@ static int sja1105_probe(struct spi_device *spi) ...@@ -3682,7 +3684,8 @@ static int sja1105_probe(struct spi_device *spi)
} }
return 0; return 0;
out:
out_destroy_workers:
while (port-- > 0) { while (port-- > 0) {
struct sja1105_port *sp = &priv->ports[port]; struct sja1105_port *sp = &priv->ports[port];
...@@ -3691,6 +3694,10 @@ static int sja1105_probe(struct spi_device *spi) ...@@ -3691,6 +3694,10 @@ static int sja1105_probe(struct spi_device *spi)
kthread_destroy_worker(sp->xmit_worker); kthread_destroy_worker(sp->xmit_worker);
} }
out_unregister_switch:
dsa_unregister_switch(ds);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment