lib: fix __fdt_parse_region()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 8 Dec 2022 01:14:20 +0000 (02:14 +0100)
committerAnup Patel <anup@brainfault.org>
Fri, 9 Dec 2022 05:56:39 +0000 (11:26 +0530)
commitc2be21432c00840e6b2d2e5cdc668b5ee6180738
tree14bd2031bd2be1243505d82e863f2209d1113a15
parent8b00be692740736e989776b312c87dc9c0b403c8
lib: fix __fdt_parse_region()

If fdt_getprop() returns NULL, this indicates an error. In this case lenp
is set to an error code. But even if lenp = 0 we should not continue.

If fdt_getprop() returns a wider value than we expect this is a separate
error condition.

In both cases the device-tree is invalid.

Addresses-Coverity-ID: 1529703 ("Dereference after null check")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/fdt/fdt_domain.c