From: Philipp Stanner <phasta@kernel.org>
To: "Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Philipp Stanner <phasta@kernel.org>
Subject: [PATCH] PCI: Follow-up fix for BAR hardening
Date: Wed, 5 Mar 2025 08:53:55 +0100 [thread overview]
Message-ID: <20250305075354.118331-2-phasta@kernel.org> (raw)
Fixes a bug where variables were used before being initialized.
To be squashed into commit "PCI: Check BAR index for validity"
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
Fix for this already applied patch:
https://lore.kernel.org/all/20250304143112.104190-2-phasta@kernel.org/
---
drivers/pci/iomap.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/iomap.c b/drivers/pci/iomap.c
index 0cab82cbcc99..fe706ed946df 100644
--- a/drivers/pci/iomap.c
+++ b/drivers/pci/iomap.c
@@ -40,13 +40,14 @@ void __iomem *pci_iomap_range(struct pci_dev *dev,
if (!pci_bar_index_is_valid(bar))
return NULL;
- if (len <= offset || !start)
- return NULL;
start = pci_resource_start(dev, bar);
len = pci_resource_len(dev, bar);
flags = pci_resource_flags(dev, bar);
+ if (len <= offset || !start)
+ return NULL;
+
len -= offset;
start += offset;
if (maxlen && len > maxlen)
@@ -90,13 +91,13 @@ void __iomem *pci_iomap_wc_range(struct pci_dev *dev,
if (!pci_bar_index_is_valid(bar))
return NULL;
- if (len <= offset || !start)
- return NULL;
start = pci_resource_start(dev, bar);
len = pci_resource_len(dev, bar);
flags = pci_resource_flags(dev, bar);
+ if (len <= offset || !start)
+ return NULL;
if (flags & IORESOURCE_IO)
return NULL;
--
2.48.1
next reply other threads:[~2025-03-05 7:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 7:53 Philipp Stanner [this message]
2025-03-05 8:07 ` [PATCH] PCI: Follow-up fix for BAR hardening Krzysztof Wilczyński
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=20250305075354.118331-2-phasta@kernel.org \
--to=phasta@kernel.org \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.