[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [PATCH] lib/ukallocbbuddy: fix addmem call with negative len



Thanks a lot for this fix!

Reviewed-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>

On 05.02.20 14:12, Hugo Lefeuvre wrote:
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;
  }


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.