Merge branch 'pci/workqueue'

- Add WQ_PERCPU to alloc_workqueue() users (Marco Crivellari)

- Replace use of system_wq with system_percpu_wq (Marco Crivellari)

- Check for failure of alloc_workqueue() to avoid NULL pointer dereferences
  (Haotian Zhang)

* pci/workqueue:
  PCI: endpoint: Add missing NULL check for alloc_workqueue()
  PCI: endpoint: Replace use of system_wq with system_percpu_wq
  PCI: Add WQ_PERCPU to alloc_workqueue() users

# Conflicts:
#	drivers/pci/endpoint/pci-ep-cfs.c
This commit is contained in:
Bjorn Helgaas
2026-02-06 17:09:32 -06:00
6 changed files with 19 additions and 8 deletions

View File

@@ -686,7 +686,7 @@ static int pci_epf_mhi_dma_init(struct pci_epf_mhi *epf_mhi)
goto err_release_tx;
}
epf_mhi->dma_wq = alloc_workqueue("pci_epf_mhi_dma_wq", 0, 0);
epf_mhi->dma_wq = alloc_workqueue("pci_epf_mhi_dma_wq", WQ_PERCPU, 0);
if (!epf_mhi->dma_wq) {
ret = -ENOMEM;
goto err_release_rx;

View File

@@ -2124,8 +2124,13 @@ static int __init epf_ntb_init(void)
{
int ret;
kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM |
WQ_HIGHPRI, 0);
kpcintb_workqueue = alloc_workqueue("kpcintb",
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
if (!kpcintb_workqueue) {
pr_err("Failed to allocate kpcintb workqueue\n");
return -ENOMEM;
}
ret = pci_epf_register_driver(&epf_ntb_driver);
if (ret) {
destroy_workqueue(kpcintb_workqueue);

View File

@@ -1188,7 +1188,7 @@ static int __init pci_epf_test_init(void)
int ret;
kpcitest_workqueue = alloc_workqueue("kpcitest",
WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
if (!kpcitest_workqueue) {
pr_err("Failed to allocate the kpcitest work queue\n");
return -ENOMEM;

View File

@@ -1651,8 +1651,13 @@ static int __init epf_ntb_init(void)
{
int ret;
kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM |
WQ_HIGHPRI, 0);
kpcintb_workqueue = alloc_workqueue("kpcintb",
WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_PERCPU, 0);
if (!kpcintb_workqueue) {
pr_err("Failed to allocate kpcintb workqueue\n");
return -ENOMEM;
}
ret = pci_epf_register_driver(&epf_ntb_driver);
if (ret) {
destroy_workqueue(kpcintb_workqueue);

View File

@@ -802,7 +802,7 @@ static struct pnv_php_slot *pnv_php_alloc_slot(struct device_node *dn)
}
/* Allocate workqueue for this slot's interrupt handling */
php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name);
php_slot->wq = alloc_workqueue("pciehp-%s", WQ_PERCPU, 0, php_slot->name);
if (!php_slot->wq) {
SLOT_WARN(php_slot, "Cannot alloc workqueue\n");
kfree(php_slot->name);

View File

@@ -80,7 +80,8 @@ static int init_slots(struct controller *ctrl)
slot->device = ctrl->slot_device_offset + i;
slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
slot->wq = alloc_workqueue("shpchp-%d", 0, 0, slot->number);
slot->wq = alloc_workqueue("shpchp-%d", WQ_PERCPU, 0,
slot->number);
if (!slot->wq) {
retval = -ENOMEM;
goto error_slot;