diff mbox series

[2/6] stm32mp: bsec: add check on null size in misc ops

Message ID 20230427153632.2.Ie06da6845013adef7bc23ff4c379fda001542fa6@changeid
State Accepted
Commit 7b802e1acfc3a47e889afe22bdf47d1e52287cbe
Delegated to: Patrice Chotard
Headers show
Series stm32mp: soome changes and fixes for STM32MP13 and STM32MP15 boards | expand

Commit Message

Patrick Delaunay April 27, 2023, 1:36 p.m. UTC
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 <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-stm32mp/bsec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Patrice CHOTARD May 3, 2023, 6:27 a.m. UTC | #1
On 4/27/23 15:36, Patrick Delaunay wrote:
> 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 <patrick.delaunay@foss.st.com>
> ---
> 
>  arch/arm/mach-stm32mp/bsec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
> index f5f4b20d4776..0dc1e5c3fdc4 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) {
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index f5f4b20d4776..0dc1e5c3fdc4 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) {