Skip to content

Commit

Permalink
PCI: Allow release of resources that were never assigned
Browse files Browse the repository at this point in the history
It is 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.

Fixes: 8bb705e ("PCI: Add pci_resize_resource() for resizing BARs")
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
CC: stable@vger.kernel.org	# v4.15+
  • Loading branch information
Christian König authored and Bjorn Helgaas committed Feb 26, 2018
1 parent 6d516d6 commit c37406e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/pci/setup-res.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ void pci_release_resource(struct pci_dev *dev, int resno)
struct resource *res = dev->resource + resno;

pci_info(dev, "BAR %d: releasing %pR\n", resno, res);

if (!res->parent)
return;

release_resource(res);
res->end = resource_size(res) - 1;
res->start = 0;
Expand Down

0 comments on commit c37406e

Please sign in to comment.