Re: [PATCH v1] of: add sanity check for machine compatible string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29.05.24 11:33, Oleksij Rempel wrote:
> Add a sanity check in of_get_machine_compatible to ensure we fall back
> to the default hostname "barebox" when the machine compatible string is
> empty. This prevents scenarios where no hostname is set, which can occur
> when starting an STM32 version of Barebox as a second stage on top of
> Barebox prior to commit 1da26bfb9da2 ("common: don't fixup empty serial/
> machine_compatible strings"). This fallback makes debugging easier in
> case someone faces a similar issue.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>

Reviewed-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>

> ---
>  drivers/of/base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 2213165fd7..62d84786ae 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -3416,7 +3416,7 @@ const char *of_get_machine_compatible(void)
>  		return NULL;
>  
>  	p = strchr(name, ',');
> -	return p ? p + 1 : name;
> +	return nonempty(p ? p + 1 : name);

An alternative would be return `p ? p + 1 : nonempty(name);`, but that's
not really more readable, so the current change is alright.

Thanks!
Ahmad

>  }
>  EXPORT_SYMBOL(of_get_machine_compatible);
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux