From: Teshan Kannangara <tpk.teshan@gmail.com>
To: jgross@suse.com
Cc: sstabellini@kernel.org, oleksandr_tyshchenko@epam.com,
xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
Teshan Kannangara <tpk.teshan@gmail.com>
Subject: [PATCH] xen/platform-pci: Disable device before releasing PCI regions
Date: Tue, 13 Oct 2026 11:05:26 +0530 [thread overview]
Message-ID: <20261013053526.1336149-1-tpk.teshan@gmail.com> (raw)
The probe error paths release the PCI regions before disabling the
device. Documentation/PCI/pci.rst specifies that drivers should disable
the device before releasing its regions to prevent devices from
colliding on the same address range.
Track successfully requested BARs in a bitmask and use a common cleanup
path to disable the device before releasing those regions.
Signed-off-by: Teshan Kannangara <tpk.teshan@gmail.com>
---
drivers/xen/platform-pci.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c
index f2438232518c..a12ac57274a6 100644
--- a/drivers/xen/platform-pci.c
+++ b/drivers/xen/platform-pci.c
@@ -95,6 +95,7 @@ static int platform_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
int i, ret;
+ int requested_bars = 0;
long ioaddr;
long mmio_addr, mmio_len;
unsigned int max_nr_gframes;
@@ -115,16 +116,18 @@ static int platform_pci_probe(struct pci_dev *pdev,
if (mmio_addr == 0 || ioaddr == 0) {
dev_err(&pdev->dev, "no resources found\n");
ret = -ENOENT;
- goto pci_out;
+ goto out;
}
ret = pci_request_region(pdev, 1, DRV_NAME);
if (ret < 0)
- goto pci_out;
+ goto out;
+ requested_bars |= BIT(1);
ret = pci_request_region(pdev, 0, DRV_NAME);
if (ret < 0)
- goto mem_out;
+ goto out;
+ requested_bars |= BIT(0);
platform_mmio = mmio_addr;
platform_mmiolen = mmio_len;
@@ -165,11 +168,8 @@ static int platform_pci_probe(struct pci_dev *pdev,
if (!xen_have_vector_callback)
free_irq(pdev->irq, pdev);
out:
- pci_release_region(pdev, 0);
-mem_out:
- pci_release_region(pdev, 1);
-pci_out:
pci_disable_device(pdev);
+ pci_release_selected_regions(pdev, requested_bars);
return ret;
}
--
2.53.0
next reply other threads:[~2026-10-13 5:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 5:35 Teshan Kannangara [this message]
2026-10-13 5:36 Teshan Kannangara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261013053526.1336149-1-tpk.teshan@gmail.com \
--to=tpk.teshan@gmail.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr_tyshchenko@epam.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®