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:4d7525085a
("net: dsa: sja1105: offload the Credit-Based Shaper qdisc") Fixes:a68578c20a
("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>
This commit is contained in:
Родитель
ba61cf167c
Коммит
dc596e3fe6
|
@ -3646,8 +3646,10 @@ static int sja1105_probe(struct spi_device *spi)
|
|||
priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers,
|
||||
sizeof(struct sja1105_cbs_entry),
|
||||
GFP_KERNEL);
|
||||
if (!priv->cbs)
|
||||
return -ENOMEM;
|
||||
if (!priv->cbs) {
|
||||
rc = -ENOMEM;
|
||||
goto out_unregister_switch;
|
||||
}
|
||||
}
|
||||
|
||||
/* Connections between dsa_port and sja1105_port */
|
||||
|
@ -3672,7 +3674,7 @@ static int sja1105_probe(struct spi_device *spi)
|
|||
dev_err(ds->dev,
|
||||
"failed to create deferred xmit thread: %d\n",
|
||||
rc);
|
||||
goto out;
|
||||
goto out_destroy_workers;
|
||||
}
|
||||
skb_queue_head_init(&sp->xmit_queue);
|
||||
sp->xmit_tpid = ETH_P_SJA1105;
|
||||
|
@ -3682,7 +3684,8 @@ static int sja1105_probe(struct spi_device *spi)
|
|||
}
|
||||
|
||||
return 0;
|
||||
out:
|
||||
|
||||
out_destroy_workers:
|
||||
while (port-- > 0) {
|
||||
struct sja1105_port *sp = &priv->ports[port];
|
||||
|
||||
|
@ -3691,6 +3694,10 @@ out:
|
|||
|
||||
kthread_destroy_worker(sp->xmit_worker);
|
||||
}
|
||||
|
||||
out_unregister_switch:
|
||||
dsa_unregister_switch(ds);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче