wifi: iwl4965: Add missing check for create_singlethread_workqueue()
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 9 Feb 2023 01:07:48 +0000 (09:07 +0800)
committerKalle Valo <kvalo@kernel.org>
Mon, 13 Feb 2023 15:17:27 +0000 (17:17 +0200)
Add the check for the return value of the create_singlethread_workqueue()
in order to avoid NULL pointer dereference.

Fixes: b481de9ca074 ("[IWLWIFI]: add iwlwifi wireless drivers")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230209010748.45454-1-jiasheng@iscas.ac.cn
drivers/net/wireless/intel/iwlegacy/4965-mac.c

index 721b4042b4bf710de67eb0233fd218f5c0250a25..4d3c544ff2e66c134d88d0d186e1eb063ef1407a 100644 (file)
@@ -6211,10 +6211,12 @@ out:
        mutex_unlock(&il->mutex);
 }
 
-static void
+static int
 il4965_setup_deferred_work(struct il_priv *il)
 {
        il->workqueue = create_singlethread_workqueue(DRV_NAME);
+       if (!il->workqueue)
+               return -ENOMEM;
 
        init_waitqueue_head(&il->wait_command_queue);
 
@@ -6233,6 +6235,8 @@ il4965_setup_deferred_work(struct il_priv *il)
        timer_setup(&il->watchdog, il_bg_watchdog, 0);
 
        tasklet_setup(&il->irq_tasklet, il4965_irq_tasklet);
+
+       return 0;
 }
 
 static void
@@ -6618,7 +6622,10 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto out_disable_msi;
        }
 
-       il4965_setup_deferred_work(il);
+       err = il4965_setup_deferred_work(il);
+       if (err)
+               goto out_free_irq;
+
        il4965_setup_handlers(il);
 
        /*********************************************
@@ -6656,6 +6663,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 out_destroy_workqueue:
        destroy_workqueue(il->workqueue);
        il->workqueue = NULL;
+out_free_irq:
        free_irq(il->pci_dev->irq, il);
 out_disable_msi:
        pci_disable_msi(il->pci_dev);