memblock: Fix error path in memblock_add_region()
PATCH 1/1 memblock: Fix error path in memblock_add_region()
@type->regions should be restored if memblock_double_array() fails.
--- mm/memblock.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
mm/memblock.c +4 -0
@@ -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 ; }
Signature · 8 lines
1.7.3.4.600.g982838b0 -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · Namhyung Kim
@type->regions should be restored if
memblock_double_array()fails.Signed-off-by Namhyung Kim <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Yinghai Lu <[email protected]>--- mm/memblock.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)mm/memblock.c +0
-0
mm/memblock.c static long __init_memblock memblock_add_region(struct memblock_type *type, phys · line 388
Quoted 10 lines
mm/memblock.c +4
-0@@ -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
mm/memblock.c +2 -6
@@ -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 [email protected]. 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:"[email protected]"> [email protected] </a>
2011-02-06 (일), 09:46 -0800, Yinghai Lu:
Quoted 16 lines
we can skip the restoring.
Thanks
Yinghai
mm/memblock.c +0
-2@@ -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
mm/memblock.c static long __init_memblock memblock_add_region(struct memblock_type *type, phys · line 382
Quoted 10 lines
mm/memblock.c +2
-4-*/ -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.
Signature · 2 lines
Regards, Namhyung Kim