Re: [PATCH v2 1/3] of: reserved_mem: avoid unnecessary memory allocation when __reserved_mem_check_root() fails
From: Wandun
Date: Mon Jun 01 2026 - 21:37:53 EST
On 6/2/26 07:06, Rob Herring wrote:
On Wed, May 20, 2026 at 04:16:23PM +0800, Wandun wrote:I wasn't aware of 'b4 relay' before, this is really helpful.
There is also the 'b4 relay' that can be used for this kind of issue.
On 5/20/26 15:44, Krzysztof Kozlowski wrote:
On Tue, May 19, 2026 at 04:24:25PM +0800, Wandun Chen wrote:Hi Krzysztof,
total_reserved_mem_cnt will keep the init value (MAX_RESERVED_REGIONS)Authorship/DCO mismatch.
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>
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.
Thanks for the tip!
Best regards,
Wandun
Rob