net: qlogic: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Tue, 12 Mar 2019 07:06:47 +0000 (02:06 -0500)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Mar 2019 21:44:43 +0000 (14:44 -0700)
In case create_singlethread_workqueue fails, the fix returns
-ENOMEM to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qla3xxx.c

index 10b075bc595966ac405751ade7cda6b78ed930d7..b61b88cbc0c7ddb58b0930b2a427a18b16f16f1b 100644 (file)
@@ -3886,6 +3886,12 @@ static int ql3xxx_probe(struct pci_dev *pdev,
        netif_stop_queue(ndev);
 
        qdev->workqueue = create_singlethread_workqueue(ndev->name);
+       if (!qdev->workqueue) {
+               unregister_netdev(ndev);
+               err = -ENOMEM;
+               goto err_out_iounmap;
+       }
+
        INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work);
        INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work);
        INIT_DELAYED_WORK(&qdev->link_state_work, ql_link_state_machine_work);