PCI: endpoint: Fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Fri, 15 Mar 2019 05:07:10 +0000 (00:07 -0500)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Fri, 12 Apr 2019 14:25:09 +0000 (15:25 +0100)
In case alloc_workqueue() fails, return -ENOMEM to avoid
potential NULL pointer dereferences.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
[lorenzo.pieralisi@arm.com: commit log and code update]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
drivers/pci/endpoint/functions/pci-epf-test.c

index d0b91da..ed5cd28 100644 (file)
@@ -591,6 +591,11 @@ static int __init pci_epf_test_init(void)
 
        kpcitest_workqueue = alloc_workqueue("kpcitest",
                                             WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
+       if (!kpcitest_workqueue) {
+               pr_err("Failed to allocate the kpcitest work queue\n");
+               return -ENOMEM;
+       }
+
        ret = pci_epf_register_driver(&test_driver);
        if (ret) {
                pr_err("Failed to register pci epf test driver --> %d\n", ret);