diff mbox series

[U-Boot,v1,3/3] tdx-cfg-block: fix off by one issue

Message ID 20190201151852.13064-4-marcel@ziswiler.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series toradex: common: fix/improve config block handling | expand

Commit Message

Marcel Ziswiler Feb. 1, 2019, 3:18 p.m. UTC
From: Marcel Ziswiler <marcel.ziswiler@toradex.com>

Fix toradex_modules array off by one issue potentially leading to
spurious printout during boot e.g.

    Model: Toradex  V1.2A,

instead of

    Model: Toradex UNKNOWN MODULE V1.2A.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Max Krummenacher <max.krummenacher@toradex.com>

---

 board/toradex/common/tdx-cfg-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Igor Opaniuk March 7, 2019, 5:24 a.m. UTC | #1
Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>

On Fri, 1 Feb 2019 at 17:25, Marcel Ziswiler <marcel@ziswiler.com> wrote:
>
> From: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>
> Fix toradex_modules array off by one issue potentially leading to
> spurious printout during boot e.g.
>
>     Model: Toradex  V1.2A,
>
> instead of
>
>     Model: Toradex UNKNOWN MODULE V1.2A.
>
> Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
>
> ---
>
>  board/toradex/common/tdx-cfg-block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
> index 2fcb998ae4..b90077bedc 100644
> --- a/board/toradex/common/tdx-cfg-block.c
> +++ b/board/toradex/common/tdx-cfg-block.c
> @@ -261,7 +261,7 @@ int read_tdx_cfg_block(void)
>         }
>
>         /* Cap product id to avoid issues with a yet unknown one */
> -       if (tdx_hw_tag.prodid > (sizeof(toradex_modules) /
> +       if (tdx_hw_tag.prodid >= (sizeof(toradex_modules) /
>                                   sizeof(toradex_modules[0])))
>                 tdx_hw_tag.prodid = 0;
>
> --
> 2.20.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
diff mbox series

Patch

diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 2fcb998ae4..b90077bedc 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -261,7 +261,7 @@  int read_tdx_cfg_block(void)
 	}
 
 	/* Cap product id to avoid issues with a yet unknown one */
-	if (tdx_hw_tag.prodid > (sizeof(toradex_modules) /
+	if (tdx_hw_tag.prodid >= (sizeof(toradex_modules) /
 				  sizeof(toradex_modules[0])))
 		tdx_hw_tag.prodid = 0;