Skip to contentSkip to conversation

mm: fix invalid loop for poison_init_mem

PATCH New Jamie Iles 3 participants 3 messages Aug 3, 2011 Arm (32-bit)

lore
Share & tools
lore

Jamie Iles

author
#0 lore raw

PATCH 1/1 mm: fix invalid loop for poison_init_mem

poison_init_mem() used a loop of:

	while ((count = count - 4))

which has 2 problems - an off by one error so that we do one less word than we should, and the other is that if count == 0 then we loop forever and poison too much. On a platform with HAVE_TCM=y but nothing in the TCM's, this caused corruption and the platform failed to boot.

Cc Stephen Boyd <[email protected]>
Cc Nicolas Pitre <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mm/init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mm/init.c +1 -1
index 2fee782..91bca35 100644
@@ -441,7 +441,7 @@ static inline int free_area(unsigned long pfn, unsigned long end, char *s)
 static inline void poison_init_mem(void *s, size_t count)
 {
 	u32 *p = (u32 *)s;
-	while ((count = count - 4))
+	for (; count != 0; count -= 4)
 		*p++ = 0xe7fddef0;
 }
 
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/1 mm: fix invalid loop for poison_init_mem

Quoted 9 lines · Jamie Iles

poison_init_mem() used a loop of:

	while ((count = count - 4))

which has 2 problems - an off by one error so that we do one less word than we should, and the other is that if count == 0 then we loop forever and poison too much. On a platform with HAVE_TCM=y but nothing in the TCM's, this caused corruption and the platform failed to boot.

Quoted 4 lines
Cc Stephen Boyd <[email protected]>
Cc Nicolas Pitre <[email protected]>
Cc Russell King <[email protected]>
Quoted 20 lines
---
 arch/arm/mm/init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mm/init.c +1 -1
index 2fee782..91bca35 100644
@@ -441,7 +441,7 @@ static inline int free_area(unsigned long pfn, unsigned long end, char *s)
 static inline void poison_init_mem(void *s, size_t count)
 {
 	u32 *p = (u32 *)s;
-	while ((count = count - 4))
+	for (; count != 0; count -= 4)
 		*p++ = 0xe7fddef0;
 }
 
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 1/1 mm: fix invalid loop for poison_init_mem

In reply to Jamie Iles
Quoted 9 lines · Jamie Iles

poison_init_mem() used a loop of:

	while ((count = count - 4))

which has 2 problems - an off by one error so that we do one less word than we should, and the other is that if count == 0 then we loop forever and poison too much. On a platform with HAVE_TCM=y but nothing in the TCM's, this caused corruption and the platform failed to boot.

Quoted 13 lines
Cc Nicolas Pitre <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mm/init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mm/init.c +0 -0
index 2fee782..91bca35 100644

arch/arm/mm/init.c static inline int free_area(unsigned long pfn, unsigned long end, char *s) · line 447

Quoted 8 lines
arch/arm/mm/init.c +1 -1
@@ -441,7 +441,7 @@ static inline int free_area(unsigned long pfn, unsigned long end, char *s)
 static inline void poison_init_mem(void *s, size_t count)
 {
 	u32 *p = (u32 *)s;
-	while ((count = count - 4))
+	for (; count != 0; count -= 4)
 		*p++ = 0xe7fddef0;
 }
 

Now where's that bag...

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.