From: Patrick Delaunay Date: Thu, 27 Apr 2023 13:36:34 +0000 (+0200) Subject: stm32mp: bsec: add check on null size in misc ops X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=7b802e1acfc3a47e889afe22bdf47d1e52287cbe;p=u-boot.git stm32mp: bsec: add check on null size in misc ops Add a protection in misc bsec ops for request with null size. For example OP-TEE error occurs when get_eth_nb() return 0 in setup_mac_address() for unknown part number because U-Boot read 0 OTPs. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index f5f4b20d47..0dc1e5c3fd 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -622,7 +622,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, shadow = false; } - if ((offs % 4) || (size % 4)) + if ((offs % 4) || (size % 4) || !size) return -EINVAL; if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) { @@ -678,7 +678,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, shadow = false; } - if ((offs % 4) || (size % 4)) + if ((offs % 4) || (size % 4) || !size) return -EINVAL; if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) {