Skip to content

Commit 9d51299

Browse files
committed
net: macb: free resources in case of failure
In case macb_open() fails and user space tries to "ifup" the again the interface after this failure, the napi_enable() will reach a BUG_ON() instruction because the napi wasn't disabled the the previous macb_open() failure. So, add failure path in macb_open() that reverts the previously done operations. Fixes: b2b0414 ("net: macb: convert to phylink") Tested-by: Cristian Birsan <cristian.birsan@microchip.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent f9ff2b7 commit 9d51299

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ static int macb_open(struct net_device *dev)
25002500

25012501
err = macb_phylink_connect(bp);
25022502
if (err)
2503-
goto pm_exit;
2503+
goto reset_hw;
25042504

25052505
netif_tx_start_all_queues(dev);
25062506

@@ -2509,6 +2509,12 @@ static int macb_open(struct net_device *dev)
25092509

25102510
return 0;
25112511

2512+
reset_hw:
2513+
macb_reset_hw(bp);
2514+
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
2515+
napi_disable(&queue->napi);
2516+
macb_free_consistent(bp);
2517+
25122518
pm_exit:
25132519
pm_runtime_put_sync(&bp->pdev->dev);
25142520

0 commit comments

Comments
 (0)