From 56798b02d2664ad64f72da03e36aa9860b7d813f Mon Sep 17 00:00:00 2001 From: Kangjie Lu Date: Thu, 23 May 2019 19:20:41 +0800 Subject: [PATCH] PCI: endpoint: Fix a potential NULL pointer dereference mainline inclusion from mainline-5.1-rc1 commit 507b820009a4 category: bugfix bugzilla: 16035 CVE: NA ------------------------------------------------- In case alloc_workqueue() fails, return -ENOMEM to avoid potential NULL pointer dereferences. Signed-off-by: Kangjie Lu [lorenzo.pieralisi@arm.com: commit log and code update] Signed-off-by: Lorenzo Pieralisi Signed-off-by: Xiongfeng Wang Reviewed-by: Yao Hongbo Signed-off-by: Yang Yingliang --- drivers/pci/endpoint/functions/pci-epf-test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 4bbd26e8a9e2..26a75f58765e 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -570,6 +570,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); -- GitLab