lkml.org 
[lkml]   [2011]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] memblock: Fix error path in memblock_add_region()
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;
}

\
 
 \ /
  Last update: 2011-02-06 18:49    [W:0.044 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site