From a254a7cd711c36140b34587a69707423afee792d Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Sat, 16 Jan 2021 22:43:43 +0100 Subject: [PATCH] Fix allocation of too big size --- core/alloc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/alloc.c b/core/alloc.c index 6333646..3d3410c 100644 --- a/core/alloc.c +++ b/core/alloc.c @@ -205,10 +205,10 @@ static void *allocFromSlab(struct slabEntry *slab) void *malloc(size_t size) { - int flags; - struct slabDesc *slab; + struct slabDesc *slab = NULL; uint slubIdx; void *ret; + int flags; disable_IRQs(flags); @@ -217,6 +217,12 @@ void *malloc(size_t size) if (size <= slab->size) break; } + + if (!list_foreach_early_break(slub, slab, slubIdx)) { + pr_devel("No slab found for %d\n", size); + return NULL; + } + struct slabEntry *slabEntry; int slabIdx; list_foreach(&slab->slab, slabEntry, slabIdx)