[PATCH] net: fjes: fix potential NULL pointer dereferences
From: Kangjie Lu
Date: Mon Mar 11 2019 - 03:10:33 EST
In case alloc_workqueue fails, the fix returns -ENOMEM to avoid
ULL pointer dereferences.
Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
---
drivers/net/fjes/fjes_main.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index d3eae1239045..18c2c9e24c24 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1252,8 +1252,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 (!adapter->txrx_wq) {
+ err = -ENOMEM;
+ goto err_free_netdev;
+ }
+
adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
WQ_MEM_RECLAIM, 0);
+ if (!adapter->control_wq) {
+ err = -ENOMEM;
+ goto err_free_netdev;
+ }
INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
INIT_WORK(&adapter->raise_intr_rxdata_task,
--
2.17.1