Re: [PATCH v2 1/3] of: reserved_mem: avoid unnecessary memory allocation when __reserved_mem_check_root() fails

From: Wandun

Date: Wed May 20 2026 - 04:23:27 EST




On 5/20/26 15:44, Krzysztof Kozlowski wrote:
On Tue, May 19, 2026 at 04:24:25PM +0800, Wandun Chen wrote:
total_reserved_mem_cnt will keep the init value (MAX_RESERVED_REGIONS)
in fdt_scan_reserved_mem() if __reserved_mem_check_root() fails.

fdt_scan_reserved_mem_late() calls alloc_reserved_mem_array() to
allocate memory according to total_reserved_mem_cnt before
__reserved_mem_check_root(), so if __reserved_mem_check_root() fails,
the allocated array has nowhere to be used, so no need to allocate
memory.

Move alloc_reserved_mem_array() after __reserved_mem_check_root() to
avoid potential memory waste.

Signed-off-by: Wandun Chen <chenwandun@xxxxxxxxxxx>
Authorship/DCO mismatch.
Hi Krzysztof,

Thanks for your review.
Sorry for the mismatch. Dueto my company email server's issues with
community mailing lists, I sent the patch via my personal email.
I will add the correct 'From:' header and send a v3 patch shortly.

Best regards,
Wandun
Tested-by: Meijing Zhao <zhaomeijing@xxxxxxxxxxx>
Best regards,
Krzysztof