diff mbox

PCI: stop crashing in pci_release_resource

Message ID 20180220085813.1897-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Christian König Feb. 20, 2018, 8:58 a.m. UTC
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.

Signed-off-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
---
 drivers/pci/setup-res.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andy Shevchenko Feb. 20, 2018, 2:04 p.m. UTC | #1
On Tue, Feb 20, 2018 at 10:58 AM, Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
> 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 = dev->resource + resno;
>
> +       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.

>         release_resource(res);
>         res->end = resource_size(res) - 1;
diff mbox

Patch

diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index e815111f3f81..fd72c87a9b72 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -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;