Skip to content

Commit 85ac30f

Browse files
willdeacondavem330
authored andcommitted
fjes: Handle workqueue allocation failure
In the highly unlikely event that we fail to allocate either of the "/txrx" or "/control" workqueues, we should bail cleanly rather than blindly march on with NULL queue pointer(s) installed in the 'fjes_adapter' instance. Cc: "David S. Miller" <[email protected]> Reported-by: Nicolas Waisman <[email protected]> Link: https://lore.kernel.org/lkml/CADJ_3a8WFrs5NouXNqS5WYe7rebFP+_A5CheeqAyD_p7DFJJcg@mail.gmail.com/ Signed-off-by: Will Deacon <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 55793d2 commit 85ac30f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/net/fjes/fjes_main.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,17 @@ static int fjes_probe(struct platform_device *plat_dev)
12371237
adapter->open_guard = false;
12381238

12391239
adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
1240+
if (unlikely(!adapter->txrx_wq)) {
1241+
err = -ENOMEM;
1242+
goto err_free_netdev;
1243+
}
1244+
12401245
adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
12411246
WQ_MEM_RECLAIM, 0);
1247+
if (unlikely(!adapter->control_wq)) {
1248+
err = -ENOMEM;
1249+
goto err_free_txrx_wq;
1250+
}
12421251

12431252
INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
12441253
INIT_WORK(&adapter->raise_intr_rxdata_task,
@@ -1255,7 +1264,7 @@ static int fjes_probe(struct platform_device *plat_dev)
12551264
hw->hw_res.irq = platform_get_irq(plat_dev, 0);
12561265
err = fjes_hw_init(&adapter->hw);
12571266
if (err)
1258-
goto err_free_netdev;
1267+
goto err_free_control_wq;
12591268

12601269
/* setup MAC address (02:00:00:00:00:[epid])*/
12611270
netdev->dev_addr[0] = 2;
@@ -1277,6 +1286,10 @@ static int fjes_probe(struct platform_device *plat_dev)
12771286

12781287
err_hw_exit:
12791288
fjes_hw_exit(&adapter->hw);
1289+
err_free_control_wq:
1290+
destroy_workqueue(adapter->control_wq);
1291+
err_free_txrx_wq:
1292+
destroy_workqueue(adapter->txrx_wq);
12801293
err_free_netdev:
12811294
free_netdev(netdev);
12821295
err_out:

0 commit comments

Comments
 (0)