Skip to contentSkip to conversation

mm/memblock.c: using uninitialized value idx in memblock_add_range()

RFC In review [email protected] 2 participants 2 messages Sep 8, 2017 – Sep 12, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 mm/memblock.c: using uninitialized value idx in memblock_add_range()

From: Gioh Kim <[email protected]>

In memblock_add_range(), idx variable is a local value but I cannot find initialization of idx value. I checked idx value on my Qemu emulator. It was zero. Is there any hidden initialization code?

---
 mm/memblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memblock.c +1 -1
index 7b8a5db..23374bc 100644
@@ -515,7 +515,7 @@ int __init_memblock memblock_add_range(struct memblock_type *type,
 	bool insert = false;
 	phys_addr_t obase = base;
 	phys_addr_t end = base + memblock_cap_size(base, &size);
-	int idx, nr_new;
+	int idx = 0, nr_new;
 	struct memblock_region *rgn;
 
 	if (!size)
Signature · 7 lines
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 6 lines · On Sat 09-09-17 00:15:33, [email protected] wrote:

From: Gioh Kim <[email protected]>

In memblock_add_range(), idx variable is a local value but I cannot find initialization of idx value. I checked idx value on my Qemu emulator. It was zero. Is there any hidden initialization code?

Yes for_each_memblock_type. Ugly as hell! Something to clean up I guess. Just make the index explicit argument of the macro.

Quoted 21 lines
---
 mm/memblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memblock.c +1 -1
index 7b8a5db..23374bc 100644
@@ -515,7 +515,7 @@ int __init_memblock memblock_add_range(struct memblock_type *type,
 	bool insert = false;
 	phys_addr_t obase = base;
 	phys_addr_t end = base + memblock_cap_size(base, &size);
-	int idx, nr_new;
+	int idx = 0, nr_new;
 	struct memblock_region *rgn;
 
 	if (!size)
Signature · 1 line
2.7.4
Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>