diff mbox series

[1/1] lib: utils: check correct value in fdt_node_offset_by_compatible

Message ID 20240408073733.49356-1-heinrich.schuchardt@canonical.com
State Accepted
Headers show
Series [1/1] lib: utils: check correct value in fdt_node_offset_by_compatible | expand

Commit Message

Heinrich Schuchardt April 8, 2024, 7:37 a.m. UTC
After calling fdt_node_offset_by_compatible() we must check its return
value and not an unrelated value.

Addresses-Coverity-ID: 1584993 Logically dead code
Fixes: 67ce5a763cfb ("platform: generic: Add support for specify coldboot harts in DT")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 lib/utils/fdt/fdt_fixup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anup Patel April 10, 2024, 5:19 a.m. UTC | #1
On Mon, Apr 8, 2024 at 1:07 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> After calling fdt_node_offset_by_compatible() we must check its return
> value and not an unrelated value.
>
> Addresses-Coverity-ID: 1584993 Logically dead code
> Fixes: 67ce5a763cfb ("platform: generic: Add support for specify coldboot harts in DT")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

LGTM.

Reviewed-by: Anup Patel <anup@brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup


> ---
>  lib/utils/fdt/fdt_fixup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index 194e55b..974b1b8 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -394,7 +394,7 @@ void fdt_config_fixup(void *fdt)
>                 return;
>
>         config_offset = fdt_node_offset_by_compatible(fdt, chosen_offset, "opensbi,config");
> -       if (chosen_offset < 0)
> +       if (config_offset < 0)
>                 return;
>
>         fdt_nop_node(fdt, config_offset);
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
index 194e55b..974b1b8 100644
--- a/lib/utils/fdt/fdt_fixup.c
+++ b/lib/utils/fdt/fdt_fixup.c
@@ -394,7 +394,7 @@  void fdt_config_fixup(void *fdt)
 		return;
 
 	config_offset = fdt_node_offset_by_compatible(fdt, chosen_offset, "opensbi,config");
-	if (chosen_offset < 0)
+	if (config_offset < 0)
 		return;
 
 	fdt_nop_node(fdt, config_offset);