net: qlge: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Mon, 11 Mar 2019 06:53:15 +0000 (01:53 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Mar 2019 23:16:22 +0000 (16:16 -0700)
In case alloc_ordered_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/qlge/qlge_main.c

index 096515c..07e1c62 100644 (file)
@@ -4681,6 +4681,11 @@ static int ql_init_device(struct pci_dev *pdev, struct net_device *ndev,
         */
        qdev->workqueue = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM,
                                                  ndev->name);
+       if (!qdev->workqueue) {
+               err = -ENOMEM;
+               goto err_out2;
+       }
+
        INIT_DELAYED_WORK(&qdev->asic_reset_work, ql_asic_reset_work);
        INIT_DELAYED_WORK(&qdev->mpi_reset_work, ql_mpi_reset_work);
        INIT_DELAYED_WORK(&qdev->mpi_work, ql_mpi_work);