lkml.org 
[lkml]   [2020]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 014/206] PCI: Allow pci_resize_resource() for devices on root bus
    Date
    From: Ard Biesheuvel <ardb@kernel.org>

    [ Upstream commit d09ddd8190fbdc07696bf34b548ae15aa1816714 ]

    When resizing a BAR, pci_reassign_bridge_resources() is invoked to bring
    the bridge windows of parent bridges in line with the new BAR assignment.

    This assumes the device whose BAR is being resized lives on a subordinate
    bus, but this is not necessarily the case. A device may live on the root
    bus, in which case dev->bus->self is NULL, and passing a NULL pci_dev
    pointer to pci_reassign_bridge_resources() will cause it to crash.

    So let's make the call to pci_reassign_bridge_resources() conditional on
    whether dev->bus->self is non-NULL in the first place.

    Fixes: 8bb705e3e79d84e7 ("PCI: Add pci_resize_resource() for resizing BARs")
    Link: https://lore.kernel.org/r/20200421162256.26887-1-ardb@kernel.org
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/pci/setup-res.c | 9 +++++----
    1 file changed, 5 insertions(+), 4 deletions(-)

    diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
    index d8ca40a976934..d21fa04fa44d2 100644
    --- a/drivers/pci/setup-res.c
    +++ b/drivers/pci/setup-res.c
    @@ -439,10 +439,11 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size)
    res->end = res->start + pci_rebar_size_to_bytes(size) - 1;

    /* Check if the new config works by trying to assign everything. */
    - ret = pci_reassign_bridge_resources(dev->bus->self, res->flags);
    - if (ret)
    - goto error_resize;
    -
    + if (dev->bus->self) {
    + ret = pci_reassign_bridge_resources(dev->bus->self, res->flags);
    + if (ret)
    + goto error_resize;
    + }
    return 0;

    error_resize:
    --
    2.25.1


    \
     
     \ /
      Last update: 2020-06-23 22:36    [W:4.146 / U:0.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site