[PATCH 2/2] board: st: common: add uclass_get_device_by_driver()'s return value check

Patrick DELAUNAY patrick.delaunay at foss.st.com
Tue Feb 24 11:36:17 CET 2026


Hi,

On 2/11/26 15:32, Patrice Chotard wrote:
> class_get_device_by_driver()'s return value is not checked, in case of BSEC
> driver is not probed, dev is not set and used just after as parameter of
> misc_read() which leads to a Synchronous Abort.
>
> Add uclass_get_device_by_driver()'s return value check to fix it.
>
> Signed-off-by: Patrice Chotard <patrice.chotard at foss.st.com>
> ---
>   board/st/common/cmd_stboard.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c
> index d77046499a0..58d9f205b92 100644
> --- a/board/st/common/cmd_stboard.c
> +++ b/board/st/common/cmd_stboard.c
> @@ -92,6 +92,11 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, int argc,
>   					  DM_DRIVER_GET(stm32mp_bsec),
>   					  &dev);
>   
> +	if (ret) {
> +		puts("Can't get BSEC device\n");
> +		return CMD_RET_FAILURE;
> +	}
> +
>   	ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD),
>   			&otp, sizeof(otp));
>   
>


Reviewed-by: Patrick Delaunay <patrick.delaunay at foss.st.com>

Thanks
Patrick



More information about the U-Boot mailing list