[PATCH 2/2] pci: mvebu: Fix uninitialized variable in mvebu_get_target_attr()

Uwe Kleine-König uwe at kleine-koenig.org
Sun Nov 9 03:10:32 PST 2014


From: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>

This is the same fix that was applied to the Linux kernel in commit
56fab6e18944 (PCI: mvebu: Fix uninitialized variable in
mvebu_get_tgt_attr()).

Fixes: 5a9ba98 ("pci: mvebu: Add PCIe driver")
Signed-off-by: Uwe Kleine-König <uwe at kleine-koenig.org>
---
Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
 drivers/pci/pci-mvebu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-mvebu.c b/drivers/pci/pci-mvebu.c
index 45befbb..a314a68 100644
--- a/drivers/pci/pci-mvebu.c
+++ b/drivers/pci/pci-mvebu.c
@@ -240,7 +240,7 @@ static int mvebu_get_target_attr(struct device_node *np, int devfn,
 	rangesz = pna + na + ns;
 	nranges = rlen / sizeof(__be32) / rangesz;
 
-	for (i = 0; i < nranges; i++) {
+	for (i = 0; i < nranges; i++, range += rangesz) {
 		u32 flags = of_read_number(range, 1);
 		u32 slot = of_read_number(range + 1, 1);
 		u64 cpuaddr = of_read_number(range + na, pna);
@@ -250,14 +250,14 @@ static int mvebu_get_target_attr(struct device_node *np, int devfn,
 			rtype = IORESOURCE_IO;
 		else if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_MEM32)
 			rtype = IORESOURCE_MEM;
+		else
+			continue;
 
 		if (slot == PCI_SLOT(devfn) && type == rtype) {
 			*target = DT_CPUADDR_TO_TARGET(cpuaddr);
 			*attr = DT_CPUADDR_TO_ATTR(cpuaddr);
 			return 0;
 		}
-
-		range += rangesz;
 	}
 
 	return -ENOENT;
-- 
2.1.1




More information about the barebox mailing list