[kvm-unit-tests PATCH v4 04/17] devicetree: fix dt_get_memory_params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Index nr was overreaching with its indexing. It should only
index the caller's regs array. We need a different index for
the memory nodes' reg properties.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx>
Tested-by: Laurent Vivier <lvivier@xxxxxxxxxx>

---
The next patch needs this fix.
---
 lib/devicetree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/devicetree.c b/lib/devicetree.c
index 36cb28610ff41..a5c7f7c69ddfd 100644
--- a/lib/devicetree.c
+++ b/lib/devicetree.c
@@ -165,22 +165,24 @@ int dt_pbus_get_base_compatible(const char *compatible,
 int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs)
 {
 	const char *pn = "device_type", *pv = "memory";
-	int node, ret, pl = strlen(pv) + 1, nr = 0;
+	int node, ret, reg_idx, pl = strlen(pv) + 1, nr = 0;
 	struct dt_pbus_reg reg;
 
 	node = fdt_node_offset_by_prop_value(fdt, -1, pn, pv, pl);
 
 	while (node >= 0) {
 
+		reg_idx = 0;
+
 		while (nr < nr_regs) {
-			ret = dt_pbus_translate_node(node, nr, &reg);
+			ret = dt_pbus_translate_node(node, reg_idx, &reg);
 			if (ret == -FDT_ERR_NOTFOUND)
 				break;
 			if (ret < 0)
 				return ret;
 			regs[nr].addr = reg.addr;
 			regs[nr].size = reg.size;
-			++nr;
+			++nr, ++reg_idx;
 		}
 
 		node = fdt_node_offset_by_prop_value(fdt, node, pn, pv, pl);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux