[PATCH 16/22] of: fdt: silence possible static analyzer false positive
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Mar 13 00:34:39 PDT 2025
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.fatoum at 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
More information about the barebox
mailing list