diff options
author | Christian König <ckoenig.leichtzumerken@gmail.com> | 2018-02-26 14:51:13 -0600 |
---|---|---|
committer | Bjorn Helgaas <helgaas@kernel.org> | 2018-02-26 14:51:13 -0600 |
commit | c37406e05d1e541df40b8b81c4bd40753fcaf414 (patch) | |
tree | 80e17f2555b2ca4b030a76a1708af54b5d59d5b7 /drivers/pci/setup-res.c | |
parent | 6d516d6798cdfc073aa2fa11dd5a5d72f3906ae5 (diff) |
PCI: Allow release of resources that were never assigned
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: 8bb705e3e79d ("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+
Diffstat (limited to 'drivers/pci/setup-res.c')
-rw-r--r-- | drivers/pci/setup-res.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 369d48d6c6f1..365447240d95 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -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; |