From: Philipp Stanner <pstanner@redhat.com>
To: stanner@redhat.com
Cc: Philipp Stanner <pstanner@redhat.com>,
stable@vger.kernel.org, Danilo Krummrich <dakr@redhat.com>,
Arnd Bergmann <arnd@kernel.org>, Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH v5 1/5] lib/pci_iomap.c: fix cleanup bugs in pci_iounmap()
Date: Thu, 4 Jan 2024 10:05:36 +0100 [thread overview]
Message-ID: <20240104090539.10299-3-pstanner@redhat.com> (raw)
In-Reply-To: <20240104090539.10299-2-pstanner@redhat.com>
pci_iounmap() in lib/pci_iomap.c is supposed to check whether an address
is within ioport-range IF the config specifies that ioports exist. If
so, the port should be unmapped with ioport_unmap(). If not, it's a
generic MMIO address that has to be passed to iounmap().
The bugs are:
1. ioport_unmap() is missing entirely, so this function will never
actually unmap a port.
2. the #ifdef for the ioport-ranges accidentally also guards
iounmap(), potentially compiling an empty function. This would
cause the mapping to be leaked.
Implement the missing call to ioport_unmap().
Move the guard so that iounmap() will always be part of the function.
CC: <stable@vger.kernel.org> # v5.15+
Fixes: 316e8d79a095 ("pci_iounmap'2: Electric Boogaloo: try to make sense of it all")
Reported-by: Danilo Krummrich <dakr@redhat.com>
Suggested-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
lib/pci_iomap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c
index ce39ce9f3526..6e144b017c48 100644
--- a/lib/pci_iomap.c
+++ b/lib/pci_iomap.c
@@ -168,10 +168,12 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *p)
uintptr_t start = (uintptr_t) PCI_IOBASE;
uintptr_t addr = (uintptr_t) p;
- if (addr >= start && addr < start + IO_SPACE_LIMIT)
+ if (addr >= start && addr < start + IO_SPACE_LIMIT) {
+ ioport_unmap(p);
return;
- iounmap(p);
+ }
#endif
+ iounmap(p);
}
EXPORT_SYMBOL(pci_iounmap);
--
2.43.0
next parent reply other threads:[~2024-01-04 9:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240104090539.10299-2-pstanner@redhat.com>
2024-01-04 9:05 ` Philipp Stanner [this message]
2024-01-04 9:07 [PATCH v5 RESEND 0/5] Regather scattered PCI-Code Philipp Stanner
2024-01-04 9:07 ` [PATCH v5 1/5] lib/pci_iomap.c: fix cleanup bugs in pci_iounmap() Philipp Stanner
-- strict thread matches above, loose matches on Subject: below --
2023-12-13 10:49 [PATCH v5 0/5] Regather scattered PCI-Code Philipp Stanner
2023-12-13 10:49 ` [PATCH v5 1/5] lib/pci_iomap.c: fix cleanup bugs in pci_iounmap() Philipp Stanner
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=20240104090539.10299-3-pstanner@redhat.com \
--to=pstanner@redhat.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=dakr@redhat.com \
--cc=stable@vger.kernel.org \
--cc=stanner@redhat.com \
/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