linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix invalid loop for poison_init_mem
@ 2011-08-03 15:35 Jamie Iles
  2011-08-03 15:50 ` Nicolas Pitre
  2011-08-03 16:44 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Jamie Iles @ 2011-08-03 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

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 <sboyd@codeaurora.org>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 arch/arm/mm/init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 2fee782..91bca35 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -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;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] mm: fix invalid loop for poison_init_mem
  2011-08-03 15:35 [PATCH] mm: fix invalid loop for poison_init_mem Jamie Iles
@ 2011-08-03 15:50 ` Nicolas Pitre
  2011-08-03 16:44 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2011-08-03 15:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 3 Aug 2011, Jamie Iles wrote:

> 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 <sboyd@codeaurora.org>
> Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>

Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>


> ---
>  arch/arm/mm/init.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 2fee782..91bca35 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -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;
>  }
>  
> -- 
> 1.7.4.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] mm: fix invalid loop for poison_init_mem
  2011-08-03 15:35 [PATCH] mm: fix invalid loop for poison_init_mem Jamie Iles
  2011-08-03 15:50 ` Nicolas Pitre
@ 2011-08-03 16:44 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2011-08-03 16:44 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/03/2011 08:35 AM, Jamie Iles wrote:
> 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.
>

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

>
> Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> ---
>  arch/arm/mm/init.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 2fee782..91bca35 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -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...

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-03 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-03 15:35 [PATCH] mm: fix invalid loop for poison_init_mem Jamie Iles
2011-08-03 15:50 ` Nicolas Pitre
2011-08-03 16:44 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).