drivers/pci/msi/msi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
In msix_capability_init(), if msix_setup_interrupts()
fails, call iounmap() to release the memory allocated
by msix_map_region().
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
drivers/pci/msi/msi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 34d664139f48..e010ecd9f90d 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -737,7 +737,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
ret = msix_setup_interrupts(dev, entries, nvec, affd);
if (ret)
- goto out_disable;
+ goto out_unmap;
/* Disable INTX */
pci_intx_for_msi(dev, 0);
@@ -758,6 +758,8 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
pcibios_free_irq(dev);
return 0;
+out_unmap:
+ iounmap(dev->msix_base);
out_disable:
dev->msix_enabled = 0;
pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE, 0);
--
2.25.1
On Sun, Jan 25, 2026 at 10:44:52PM +0800, Haoxiang Li wrote: > In msix_capability_init(), if msix_setup_interrupts() > fails, call iounmap() to release the memory allocated > by msix_map_region(). > > Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn> > --- > drivers/pci/msi/msi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c > index 34d664139f48..e010ecd9f90d 100644 > --- a/drivers/pci/msi/msi.c > +++ b/drivers/pci/msi/msi.c > @@ -737,7 +737,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries, > > ret = msix_setup_interrupts(dev, entries, nvec, affd); > if (ret) > - goto out_disable; > + goto out_unmap; > > /* Disable INTX */ > pci_intx_for_msi(dev, 0); > @@ -758,6 +758,8 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries, > pcibios_free_irq(dev); > return 0; > > +out_unmap: > + iounmap(dev->msix_base); Maybe Thomas has already applied this, and if not, he should chime in. Personally, I would prefer if msix_map_region() were renamed and made to return the phys_addr instead of returning the ioremapped address. That way both the ioremap() and the iounmap() on failure would be in msix_capability_init() so it's easier to review. > out_disable: > dev->msix_enabled = 0; > pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE, 0); > -- > 2.25.1 >
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 1a8d4c6ecb4c81261bcdf13556abd4a958eca202
Gitweb: https://git.kernel.org/tip/1a8d4c6ecb4c81261bcdf13556abd4a958eca202
Author: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
AuthorDate: Sun, 25 Jan 2026 22:44:52 +08:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Mon, 26 Jan 2026 09:46:48 +01:00
PCI/MSI: Unmap MSI-X region on error
msix_capability_init() fails to unmap the MSI-X region if
msix_setup_interrupts() fails.
Add the missing iounmap() for that error path.
[ tglx: Massaged change log ]
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260125144452.2103812-1-lihaoxiang@isrc.iscas.ac.cn
---
drivers/pci/msi/msi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 34d6641..e010ecd 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -737,7 +737,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
ret = msix_setup_interrupts(dev, entries, nvec, affd);
if (ret)
- goto out_disable;
+ goto out_unmap;
/* Disable INTX */
pci_intx_for_msi(dev, 0);
@@ -758,6 +758,8 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
pcibios_free_irq(dev);
return 0;
+out_unmap:
+ iounmap(dev->msix_base);
out_disable:
dev->msix_enabled = 0;
pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE, 0);
© 2016 - 2026 Red Hat, Inc.