Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1620504

[PATCH] PCI: Improve __pci_read_base robustness

From Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Newsgroups linux.kernel
Subject [PATCH] PCI: Improve __pci_read_base robustness
Date 2017-04-10 19:50 +0200
Message-ID <tuLBT-3UP-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Local variables 'l' and 'sz' are uninitialized. Normally, they would
be initialized by pci_read_config_dword() but when an error occurs,
some drivers immediately return an error code, which leaves the
argument uninitialized.

Provide a safe initial value to make the code more robust.

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
 drivers/pci/probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index d266d800f246..6fb929bd7040 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -175,7 +175,7 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar)
 int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 		    struct resource *res, unsigned int pos)
 {
-	u32 l, sz, mask;
+	u32 l = 0, sz = 0, mask;
 	u64 l64, sz64, mask64;
 	u16 orig_cmd;
 	struct pci_bus_region region, inverted_region;
-- 
2.11.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] PCI: Improve __pci_read_base robustness Marc Gonzalez <marc_gonzalez@sigmadesigns.com> - 2017-04-10 19:50 +0200
  Re: [PATCH] PCI: Improve __pci_read_base robustness Bjorn Helgaas <helgaas@kernel.org> - 2017-04-18 21:20 +0200

csiph-web