[PATCH 11/16] board: stm32mp1: check env_get result in board_late_init

2020-03-31 Thread Patrick Delaunay
This patch avoids crash in strcmp when the boot_device is not
present in environment (this case should be never occur)

Signed-off-by: Patrick Delaunay 
---

 board/st/stm32mp1/stm32mp1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 89a088cd28..fff4cef2c2 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -753,7 +753,8 @@ int board_late_init(void)
 
/* Check the boot-source to disable bootdelay */
boot_device = env_get("boot_device");
-   if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
+   if (boot_device &&
+   (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb")))
env_set("bootdelay", "0");
 
return 0;
-- 
2.17.1



Re: [PATCH 11/16] board: stm32mp1: check env_get result in board_late_init

2020-04-01 Thread Wolfgang Denk
Dear Patrick Delaunay,

In message 
<20200331180330.11.Ic051e25812481db408f2431c7962da1db1f198fb@changeid> you 
wrote:
> This patch avoids crash in strcmp when the boot_device is not
> present in environment (this case should be never occur)
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  board/st/stm32mp1/stm32mp1.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 89a088cd28..fff4cef2c2 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -753,7 +753,8 @@ int board_late_init(void)
>  
>   /* Check the boot-source to disable bootdelay */
>   boot_device = env_get("boot_device");
> - if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
> + if (boot_device &&
> + (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb")))
>   env_set("bootdelay", "0");

I think this is generally a bad idea.  You should have more respect
to the intentions of your users.  If a user defines a specific
bootdelay setting in his environment, this must be respected.

I really hate vendors who believe they know better than me what I
want or what is good to me.  Please get rid of such stuff.

"bootdelay" is an environment variable that is intentionally user
definable. You must never mess with those.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"Everything should be made as simple as possible, but not simpler."
- Albert Einstein


Re: [Uboot-stm32] [PATCH 11/16] board: stm32mp1: check env_get result in board_late_init

2020-04-01 Thread Patrice CHOTARD
Hi Patrick

On 3/31/20 6:04 PM, Patrick Delaunay wrote:
> This patch avoids crash in strcmp when the boot_device is not
> present in environment (this case should be never occur)
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  board/st/stm32mp1/stm32mp1.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 89a088cd28..fff4cef2c2 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -753,7 +753,8 @@ int board_late_init(void)
>  
>   /* Check the boot-source to disable bootdelay */
>   boot_device = env_get("boot_device");
> - if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
> + if (boot_device &&
> + (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb")))
>   env_set("bootdelay", "0");
>  
>   return 0;

Reviewed-by: Patrice Chotard 

Thanks