net: thunder: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Mon, 11 Mar 2019 06:05:41 +0000 (01:05 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Mar 2019 20:34:31 +0000 (13:34 -0700)
In case alloc_ordered_workqueue fails, the fix reports the error
and returns -ENOMEM.

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

index 503cfadff4ace4c0c7858bba02a0322656550e82..aa2be480719134f720e9487a3c71b4272cc8efe3 100644 (file)
@@ -2234,6 +2234,12 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        nic->nicvf_rx_mode_wq = alloc_ordered_workqueue("nicvf_rx_mode_wq_VF%d",
                                                        WQ_MEM_RECLAIM,
                                                        nic->vf_id);
+       if (!nic->nicvf_rx_mode_wq) {
+               err = -ENOMEM;
+               dev_err(dev, "Failed to allocate work queue\n");
+               goto err_unregister_interrupts;
+       }
+
        INIT_WORK(&nic->rx_mode_work.work, nicvf_set_rx_mode_task);
        spin_lock_init(&nic->rx_mode_wq_lock);
        mutex_init(&nic->rx_mode_mtx);