From ce51dcbd84209527eb82a64a3ce831bcac82d166 Mon Sep 17 00:00:00 2001 From: Tharaka Jayasena <9dmpires2k17.tuj@gmail.com> Date: Mon, 16 Nov 2026 19:02:30 +0530 Subject: [PATCH] libfdt: Zero the padding after a property value fdt_setprop() and fdt_appendprop() size the value to FDT_TAGALIGN(len) but copy only len bytes, so the padding keeps stale data: the old value's tail when a property shrinks, or bytes of the following tags when space is inserted. The devicetree specification requires the padding to be zeroed, so clear it. Signed-off-by: Tharaka Jayasena <9dmpires2k17.tuj@gmail.com> Signed-off-by: David Gibson --- libfdt/fdt_rw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index 850aafe..4a5fafa 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -288,6 +288,7 @@ int fdt_setprop_placeholder_namelen(void *fdt, int nodeoffset, const char *name, if (err) return err; + memset(prop->data + len, 0, FDT_TAGALIGN(len) - len); *prop_data = prop->data; return 0; } @@ -340,12 +341,14 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, return err; prop->len = cpu_to_fdt32(newlen); memcpy(prop->data + oldlen, val, len); + memset(prop->data + newlen, 0, FDT_TAGALIGN(newlen) - newlen); } else { err = fdt_add_property_(fdt, nodeoffset, name, strlen(name), len, &prop); if (err) return err; memcpy(prop->data, val, len); + memset(prop->data + len, 0, FDT_TAGALIGN(len) - len); } return 0; }