All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memblock: Fix error path in memblock_add_region()
@ 2011-02-06 13:31 ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2011-02-06 13:31 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel, Benjamin Herrenschmidt, Yinghai Lu

@type->regions should be restored if memblock_double_array() fails.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Yinghai Lu <yinghai@kernel.org>
---
 mm/memblock.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index bdba245d8afd..49284f9f99a6 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -379,6 +379,10 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
 	 */
 	if (type->cnt == type->max && memblock_double_array(type)) {
 		type->cnt--;
+		for (++i; i < type->cnt; i++) {
+			type->regions[i].base = type->regions[i+1].base;
+			type->regions[i].size = type->regions[i+1].size;
+		}
 		return -1;
 	}
 
-- 
1.7.3.4.600.g982838b0


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

* [PATCH] memblock: Fix error path in memblock_add_region()
@ 2011-02-06 13:31 ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2011-02-06 13:31 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel, Benjamin Herrenschmidt, Yinghai Lu

@type->regions should be restored if memblock_double_array() fails.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Yinghai Lu <yinghai@kernel.org>
---
 mm/memblock.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index bdba245d8afd..49284f9f99a6 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -379,6 +379,10 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
 	 */
 	if (type->cnt == type->max && memblock_double_array(type)) {
 		type->cnt--;
+		for (++i; i < type->cnt; i++) {
+			type->regions[i].base = type->regions[i+1].base;
+			type->regions[i].size = type->regions[i+1].size;
+		}
 		return -1;
 	}
 
-- 
1.7.3.4.600.g982838b0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] memblock: Fix error path in memblock_add_region()
  2011-02-06 13:31 ` Namhyung Kim
@ 2011-02-06 17:46   ` Yinghai Lu
  -1 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2011-02-06 17:46 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: linux-mm, linux-kernel, Benjamin Herrenschmidt

On 02/06/2011 05:31 AM, Namhyung Kim wrote:
> @type->regions should be restored if memblock_double_array() fails.
> 
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Yinghai Lu <yinghai@kernel.org>
> ---
>  mm/memblock.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index bdba245d8afd..49284f9f99a6 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -379,6 +379,10 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
>  	 */
>  	if (type->cnt == type->max && memblock_double_array(type)) {
>  		type->cnt--;
> +		for (++i; i < type->cnt; i++) {
> +			type->regions[i].base = type->regions[i+1].base;
> +			type->regions[i].size = type->regions[i+1].size;
> +		}
>  		return -1;
>  	}
>  

we can skip the restoring.

Thanks

Yinghai

diff --git a/mm/memblock.c b/mm/memblock.c
index bdba245..3231657 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -374,13 +374,9 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
 	}
 	type->cnt++;
 
-	/* The array is full ? Try to resize it. If that fails, we undo
-	 * our allocation and return an error
-	 */
-	if (type->cnt == type->max && memblock_double_array(type)) {
-		type->cnt--;
+	/* The array is full ? Try to resize it  */
+	if (type->cnt == type->max && memblock_double_array(type))
 		return -1;
-	}
 
 	return 0;
 }

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

* Re: [PATCH] memblock: Fix error path in memblock_add_region()
@ 2011-02-06 17:46   ` Yinghai Lu
  0 siblings, 0 replies; 6+ messages in thread
From: Yinghai Lu @ 2011-02-06 17:46 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: linux-mm, linux-kernel, Benjamin Herrenschmidt

On 02/06/2011 05:31 AM, Namhyung Kim wrote:
> @type->regions should be restored if memblock_double_array() fails.
> 
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Yinghai Lu <yinghai@kernel.org>
> ---
>  mm/memblock.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index bdba245d8afd..49284f9f99a6 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -379,6 +379,10 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
>  	 */
>  	if (type->cnt == type->max && memblock_double_array(type)) {
>  		type->cnt--;
> +		for (++i; i < type->cnt; i++) {
> +			type->regions[i].base = type->regions[i+1].base;
> +			type->regions[i].size = type->regions[i+1].size;
> +		}
>  		return -1;
>  	}
>  

we can skip the restoring.

Thanks

Yinghai

diff --git a/mm/memblock.c b/mm/memblock.c
index bdba245..3231657 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -374,13 +374,9 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
 	}
 	type->cnt++;
 
-	/* The array is full ? Try to resize it. If that fails, we undo
-	 * our allocation and return an error
-	 */
-	if (type->cnt == type->max && memblock_double_array(type)) {
-		type->cnt--;
+	/* The array is full ? Try to resize it  */
+	if (type->cnt == type->max && memblock_double_array(type))
 		return -1;
-	}
 
 	return 0;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] memblock: Fix error path in memblock_add_region()
  2011-02-06 17:46   ` Yinghai Lu
@ 2011-02-07  5:00     ` Namhyung Kim
  -1 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2011-02-07  5:00 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-mm, linux-kernel, Benjamin Herrenschmidt

2011-02-06 (일), 09:46 -0800, Yinghai Lu:
> we can skip the restoring.
> 
> Thanks
> 
> Yinghai
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index bdba245..3231657 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -374,13 +374,9 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
>  	}
>  	type->cnt++;
>  
> -	/* The array is full ? Try to resize it. If that fails, we undo
> -	 * our allocation and return an error
> -	 */
> -	if (type->cnt == type->max && memblock_double_array(type)) {
> -		type->cnt--;
> +	/* The array is full ? Try to resize it  */
> +	if (type->cnt == type->max && memblock_double_array(type))
>  		return -1;
> -	}
>  
>  	return 0;
>  }

Looks OK to me, too.
Thanks.


-- 
Regards,
Namhyung Kim



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

* Re: [PATCH] memblock: Fix error path in memblock_add_region()
@ 2011-02-07  5:00     ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2011-02-07  5:00 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-mm, linux-kernel, Benjamin Herrenschmidt

2011-02-06 (i? 1/4 ), 09:46 -0800, Yinghai Lu:
> we can skip the restoring.
> 
> Thanks
> 
> Yinghai
> 
> diff --git a/mm/memblock.c b/mm/memblock.c
> index bdba245..3231657 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -374,13 +374,9 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, phys
>  	}
>  	type->cnt++;
>  
> -	/* The array is full ? Try to resize it. If that fails, we undo
> -	 * our allocation and return an error
> -	 */
> -	if (type->cnt == type->max && memblock_double_array(type)) {
> -		type->cnt--;
> +	/* The array is full ? Try to resize it  */
> +	if (type->cnt == type->max && memblock_double_array(type))
>  		return -1;
> -	}
>  
>  	return 0;
>  }

Looks OK to me, too.
Thanks.


-- 
Regards,
Namhyung Kim


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2011-02-07  5:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-06 13:31 [PATCH] memblock: Fix error path in memblock_add_region() Namhyung Kim
2011-02-06 13:31 ` Namhyung Kim
2011-02-06 17:46 ` Yinghai Lu
2011-02-06 17:46   ` Yinghai Lu
2011-02-07  5:00   ` Namhyung Kim
2011-02-07  5:00     ` Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.