Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Prevent restoring assigned resources

restore_dev_resource() copies saved addresses and flags from the struct
pci_dev_resource back to the struct resource, typically, during rollback
from a failure or in preparation for a retry attempt.

If the resource is within resource tree, the resource must not be
modified as the resource tree could be corrupted. Thus, it's a bug to
call restore_dev_resource() for assigned resources (which did happen
due to logic flaws in the BAR resize rollback).

Add WARN_ON_ONCE() into restore_dev_resource() to detect such bugs easily
and return without altering the resource to prevent corruption.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org> # AVA, AMD GPU
Link: https://patch.msgid.link/20251113162628.5946-12-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
7409c1b1 db92e3fe

+4
+4
drivers/pci/setup-bus.c
··· 15 15 */ 16 16 17 17 #include <linux/bitops.h> 18 + #include <linux/bug.h> 18 19 #include <linux/init.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/module.h> ··· 135 134 static void restore_dev_resource(struct pci_dev_resource *dev_res) 136 135 { 137 136 struct resource *res = dev_res->res; 137 + 138 + if (WARN_ON_ONCE(res->parent)) 139 + return; 138 140 139 141 res->start = dev_res->start; 140 142 res->end = dev_res->end;