* [PATCH] fjes: Handle workqueue allocation failure
@ 2019-10-25 11:06 Will Deacon
2019-10-29 17:42 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Will Deacon @ 2019-10-25 11:06 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel, Will Deacon, David S. Miller, Nicolas Waisman
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" <davem@davemloft.net>
Reported-by: Nicolas Waisman <nico@semmle.com>
Link: https://lore.kernel.org/lkml/CADJ_3a8WFrs5NouXNqS5WYe7rebFP+_A5CheeqAyD_p7DFJJcg@mail.gmail.com/
Signed-off-by: Will Deacon <will@kernel.org>
---
Compile-tested only.
drivers/net/fjes/fjes_main.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index bbbc1dcb6ab5..b517c1af9de0 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1237,8 +1237,17 @@ static int fjes_probe(struct platform_device *plat_dev)
adapter->open_guard = false;
adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
+ if (unlikely(!adapter->txrx_wq)) {
+ err = -ENOMEM;
+ goto err_free_netdev;
+ }
+
adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
WQ_MEM_RECLAIM, 0);
+ if (unlikely(!adapter->control_wq)) {
+ err = -ENOMEM;
+ goto err_free_txrx_wq;
+ }
INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
INIT_WORK(&adapter->raise_intr_rxdata_task,
@@ -1255,7 +1264,7 @@ static int fjes_probe(struct platform_device *plat_dev)
hw->hw_res.irq = platform_get_irq(plat_dev, 0);
err = fjes_hw_init(&adapter->hw);
if (err)
- goto err_free_netdev;
+ goto err_free_control_wq;
/* setup MAC address (02:00:00:00:00:[epid])*/
netdev->dev_addr[0] = 2;
@@ -1277,6 +1286,10 @@ static int fjes_probe(struct platform_device *plat_dev)
err_hw_exit:
fjes_hw_exit(&adapter->hw);
+err_free_control_wq:
+ destroy_workqueue(adapter->control_wq);
+err_free_txrx_wq:
+ destroy_workqueue(adapter->txrx_wq);
err_free_netdev:
free_netdev(netdev);
err_out:
--
2.24.0.rc0.303.g954a862665-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fjes: Handle workqueue allocation failure
2019-10-25 11:06 [PATCH] fjes: Handle workqueue allocation failure Will Deacon
@ 2019-10-29 17:42 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-10-29 17:42 UTC (permalink / raw)
To: will; +Cc: netdev, linux-kernel, nico
From: Will Deacon <will@kernel.org>
Date: Fri, 25 Oct 2019 12:06:02 +0100
> 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" <davem@davemloft.net>
> Reported-by: Nicolas Waisman <nico@semmle.com>
> Link: https://lore.kernel.org/lkml/CADJ_3a8WFrs5NouXNqS5WYe7rebFP+_A5CheeqAyD_p7DFJJcg@mail.gmail.com/
> Signed-off-by: Will Deacon <will@kernel.org>
Applied, thanks Will.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-29 17:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 11:06 [PATCH] fjes: Handle workqueue allocation failure Will Deacon
2019-10-29 17:42 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).