* [PATCH] PCI: Follow-up fix for BAR hardening
@ 2025-03-05 7:53 Philipp Stanner
2025-03-05 8:07 ` Krzysztof Wilczyński
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Stanner @ 2025-03-05 7:53 UTC (permalink / raw)
To: Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Philipp Stanner
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: Follow-up fix for BAR hardening
2025-03-05 7:53 [PATCH] PCI: Follow-up fix for BAR hardening Philipp Stanner
@ 2025-03-05 8:07 ` Krzysztof Wilczyński
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Wilczyński @ 2025-03-05 8:07 UTC (permalink / raw)
To: Philipp Stanner; +Cc: Bjorn Helgaas, linux-pci, linux-kernel
Hello,
> Fixes a bug where variables were used before being initialized.
>
> To be squashed into commit "PCI: Check BAR index for validity"
Squashed against the existing code on the branch. Have a look:
https://web.git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=devres&id=ba10e5011d05f20bd71d3f765fd3a77f7577ff34
Thank you!
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-05 8:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 7:53 [PATCH] PCI: Follow-up fix for BAR hardening Philipp Stanner
2025-03-05 8:07 ` Krzysztof Wilczyński
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox