]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: st: common: add uclass_get_device_by_driver()'s return value check
authorPatrice Chotard <patrice.chotard@foss.st.com>
Wed, 11 Feb 2026 14:32:23 +0000 (15:32 +0100)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Tue, 24 Feb 2026 13:14:15 +0000 (14:14 +0100)
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@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
board/st/common/cmd_stboard.c

index d77046499a0c9dad99cbde263640161040e87a0f..58d9f205b92409500bfd005244fa5f1e1ecbda35 100644 (file)
@@ -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));