Skip to content

Commit dc596e3

Browse files
vladimirolteandavem330
authored andcommitted
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: 4d75250 ("net: dsa: sja1105: offload the Credit-Based Shaper qdisc") Fixes: a68578c ("net: dsa: Make deferred_xmit private to sja1105") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba61cf1 commit dc596e3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,8 +3646,10 @@ static int sja1105_probe(struct spi_device *spi)
36463646
priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers,
36473647
sizeof(struct sja1105_cbs_entry),
36483648
GFP_KERNEL);
3649-
if (!priv->cbs)
3650-
return -ENOMEM;
3649+
if (!priv->cbs) {
3650+
rc = -ENOMEM;
3651+
goto out_unregister_switch;
3652+
}
36513653
}
36523654

36533655
/* Connections between dsa_port and sja1105_port */
@@ -3672,7 +3674,7 @@ static int sja1105_probe(struct spi_device *spi)
36723674
dev_err(ds->dev,
36733675
"failed to create deferred xmit thread: %d\n",
36743676
rc);
3675-
goto out;
3677+
goto out_destroy_workers;
36763678
}
36773679
skb_queue_head_init(&sp->xmit_queue);
36783680
sp->xmit_tpid = ETH_P_SJA1105;
@@ -3682,7 +3684,8 @@ static int sja1105_probe(struct spi_device *spi)
36823684
}
36833685

36843686
return 0;
3685-
out:
3687+
3688+
out_destroy_workers:
36863689
while (port-- > 0) {
36873690
struct sja1105_port *sp = &priv->ports[port];
36883691

@@ -3691,6 +3694,10 @@ static int sja1105_probe(struct spi_device *spi)
36913694

36923695
kthread_destroy_worker(sp->xmit_worker);
36933696
}
3697+
3698+
out_unregister_switch:
3699+
dsa_unregister_switch(ds);
3700+
36943701
return rc;
36953702
}
36963703

0 commit comments

Comments
 (0)