Skip to contentSkip to conversation

PCI: fix a scheduling in atomic bug

PATCH In review Dan Carpenter 3 participants 4 messages Aug 12, 2021 – Aug 13, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: fix a scheduling in atomic bug

This function is often called with a spinlock held so the allocation has to be atomic. The call tree is:

pci_specified_resource_alignment() <-- takes spin_lock();
-> pci_dev_str_match()

    -> pci_dev_str_match_path()
Fixes 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci.c +1 -1
index 6714c58ce321..71baf5ff48fc 100644
@@ -269,7 +269,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,
 
 	*endptr = strchrnul(path, ';');
 
-	wpath = kmemdup_nul(path, *endptr - path, GFP_KERNEL);
+	wpath = kmemdup_nul(path, *endptr - path, GFP_ATOMIC);
 	if (!wpath)
 		return -ENOMEM;
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dan Carpenter

This function is often called with a spinlock held so the allocation has to be atomic. The call tree is:

pci_specified_resource_alignment() <-- takes spin_lock();
-> pci_dev_str_match()

    -> pci_dev_str_match_path()
Fixes 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")

This looks good to me, but I think the fixes tag is wrong. pci_dev_str_match_path() was introduced in this patch:

Fixes 45db33709ccc ("PCI: Allow specifying devices using a base bus and

path of devfns")

Thanks,

Logan

#2 lore raw
Quoted 11 lines · Logan Gunthorpe
Quoted 7 lines · Dan Carpenter

This function is often called with a spinlock held so the allocation has to be atomic. The call tree is:

pci_specified_resource_alignment() <-- takes spin_lock();
-> pci_dev_str_match()

    -> pci_dev_str_match_path()
Quoted 8 lines
Quoted 2 lines
Fixes 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")

This looks good to me, but I think the fixes tag is wrong. pci_dev_str_match_path() was introduced in this patch:

Fixes 45db33709ccc ("PCI: Allow specifying devices using a base bus and

path of devfns")

Yeah. You're right. Thanks. Thanks, Bjorn for fixing this.

regards,
dan carpenter

#3 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

This function is often called with a spinlock held so the allocation has to be atomic. The call tree is:

pci_specified_resource_alignment() <-- takes spin_lock();
-> pci_dev_str_match()

    -> pci_dev_str_match_path()
Fixes 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")

Applied with Logan's Reviewed-by and Fixes: update to pci/misc for v5.15, thanks!

Quoted 20 lines
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci.c +1 -1
index 6714c58ce321..71baf5ff48fc 100644
@@ -269,7 +269,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,
 
 	*endptr = strchrnul(path, ';');
 
-	wpath = kmemdup_nul(path, *endptr - path, GFP_KERNEL);
+	wpath = kmemdup_nul(path, *endptr - path, GFP_ATOMIC);
 	if (!wpath)
 		return -ENOMEM;
 
Signature · 1 line
2.20.1