clang-analyzer warns that aligning up newsize may end up causing an overflow. Let's stop well before that by bailing out if the unaligned size itself wouldn't fit into a malloc allocation anyway.
Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- drivers/of/fdt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 6c554af61f6f..43bb73b7a2df 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -378,6 +378,9 @@ static void *memalign_realloc(void *orig, size_t oldsize, size_t newsize) int align; void *newbuf; + if (newsize > MALLOC_MAX_SIZE) + return NULL; + /* * ARM Linux uses a single 1MiB section (with 1MiB alignment) * for mapping the devicetree, so we are not allowed to cross -- 2.39.5