[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [PATCH] lib/ukallocbbuddy: fix addmem call with negative len
Whenever len == metalen, the init region has exactly the size of the allocator metadata. In this case there is no space left for anything else and max - min - metalen is negative: calling bbuddy_addmem doesn't make sense. Only call bbuddy_addmem if there's memory left in the region. --- lib/ukallocbbuddy/bbuddy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ukallocbbuddy/bbuddy.c b/lib/ukallocbbuddy/bbuddy.c index 2a35de0..85f3e8d 100644 --- a/lib/ukallocbbuddy/bbuddy.c +++ b/lib/ukallocbbuddy/bbuddy.c @@ -508,8 +508,11 @@ struct uk_alloc *uk_allocbbuddy_init(void *base, size_t len) a->availmem = bbuddy_availmem; #endif - /* add left memory - ignore return value */ - bbuddy_addmem(a, (void *)(min + metalen), - (size_t)(max - min - metalen)); + if (max > min + metalen) { + /* add left memory - ignore return value */ + bbuddy_addmem(a, (void *)(min + metalen), + (size_t)(max - min - metalen)); + } + return a; } -- 2.7.4 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |