]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
of: reserved_mem: zero total_reserved_mem_cnt if no valid /reserved-memory entry
authorWandun Chen <chenwandun@lixiang.com>
Wed, 27 May 2026 03:29:10 +0000 (11:29 +0800)
committerRob Herring (Arm) <robh@kernel.org>
Fri, 12 Jun 2026 14:36:37 +0000 (09:36 -0500)
Prepare for storing /memreserve/ entries in the reserved_mem array.
Zero total_reserved_mem_cnt if no valid /reserved-memory entry,
instead of keeping it's initial value of MAX_RESERVED_REGIONS, this
allows accounting /memreserve entries based on total_reserved_mem_cnt
in a follow-up patch.

No functional change.

Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Link: https://patch.msgid.link/20260527032917.3385849-5-chenwandun1@gmail.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/of_reserved_mem.c

index c41f5550cb7b2dc1bbc13ce9ca6b8101ea32f4f3..82222bd45ac66f33baa3b2c80c3fe8b078952154 100644 (file)
@@ -336,11 +336,14 @@ int __init fdt_scan_reserved_mem(void)
        const void *fdt = initial_boot_params;
 
        node = fdt_path_offset(fdt, "/reserved-memory");
-       if (node < 0)
+       if (node < 0) {
+               total_reserved_mem_cnt = 0;
                return -ENODEV;
+       }
 
        if (__reserved_mem_check_root(node) != 0) {
                pr_err("Reserved memory: unsupported node format, ignoring\n");
+               total_reserved_mem_cnt = 0;
                return -EINVAL;
        }