Previously only a pointer to fdt string pool is saved to struct reserved_mem as region name. As on some architectures booting FDT will be wiped at later initialisation stages, this is breaking reserved_mem users. Copy and save the whole string into struct reserved_mem to avoid FDT lifecycle problem. Reported-by: Kevin Wheatfox <enkerewpo@xxxxxxxxxxx> Closes: https://lore.kernel.org/loongarch/ME4P282MB1397447C3C094554C7AF2E37B58E2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ Signed-off-by: Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> --- drivers/of/of_reserved_mem.c | 2 +- include/linux/of_reserved_mem.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 46e1c3fbc769..22841599cd83 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -70,7 +70,7 @@ static void __init fdt_reserved_mem_save_node(unsigned long node, const char *un } rmem->fdt_node = node; - rmem->name = uname; + strscpy(rmem->name, uname, RESERVED_MEM_NAME_LEN); rmem->base = base; rmem->size = size; diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index e338282da652..ed9de36c9cc9 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -8,8 +8,10 @@ struct of_phandle_args; struct reserved_mem_ops; +#define RESERVED_MEM_NAME_LEN 128 + struct reserved_mem { - const char *name; + char name[RESERVED_MEM_NAME_LEN]; unsigned long fdt_node; const struct reserved_mem_ops *ops; phys_addr_t base; --- base-commit: bb1b0acdcd66e0d8eedee3570d249e076b89ab32 change-id: 20240821-save_resv_name-4f2e2cb8883b Best regards, -- Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>