Skip to contentSkip to conversation

PCI: stop crashing in pci_release_resource

PATCH In review Christian König 2 participants 2 messages Feb 20, 2018 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: stop crashing in pci_release_resource

Is it entirely possible that the BIOS wasn't able to assign resources to a device. In this case don't crash in pci_release_resource() when we try to resize the resource.

---
 drivers/pci/setup-res.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/setup-res.c +3 -0
index e815111f3f81..fd72c87a9b72 100644
@@ -401,6 +401,9 @@ void pci_release_resource(struct pci_dev *dev, int resno)
 {
 	struct resource *res = dev->resource + resno;
 
+	if (!res->parent)
+		return;
+
 	dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);
 	release_resource(res);
 	res->end = resource_size(res) - 1;
Signature · 1 line
2.14.1
#1 lore raw

drivers/pci/setup-res.c void pci_release_resource(struct pci_dev *dev, int resno) · line 407

Quoted 10 lines · On Tue, Feb 20, 2018 at 10:58 AM, Christian K=C3=B6nig…

Is it entirely possible that the BIOS wasn't able to assign resources to a device. In this case don't crash in pci_release_resource() when we try to resize the resource.

        struct resource *res =3D dev->resource + resno;
drivers/pci/setup-res.c +3 -0
+       if (!res->parent)
+               return;
+
        dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res);

I would find info message is useful even in such case.

Quoted 2 lines
        release_resource(res);
        res->end =3D resource_size(res) - 1;

--=20
With Best Regards,
Andy Shevchenko