LoongArch: Avoid in-place string operation on FDT content
In init_cpu_fullname(), a constant pointer to "model" property is retrieved. It's later modified by the strsep() function, which is illegal and corrupts kernel's FDT copy. This is shown by dmesg, OF: fdt: not creating '/sys/firmware/fdt': CRC check failed Create a mutable copy of the model property and do in-place operations on the mutable copy instead. loongson_sysconf.cpuname lives across the kernel lifetime, thus manually releasing isn't necessary. Also move the of_node_put() call for the root node after the usage of its property, since of_node_put() decreases the reference counter thus usage after the call is unsafe. Cc: stable@vger.kernel.org Fixes: 44a01f1f ("LoongArch: Parsing CPU-related information from DTS") Reviewed-by:Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by:
Yao Zi <ziyao@disroot.org> Signed-off-by:
Huacai Chen <chenhuacai@loongson.cn>
Loading
Please register or sign in to comment