Skip to content

Commit

Permalink
stm32mp: bsec: add check on null size in misc ops
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Patrice Chotard <[email protected]>
  • Loading branch information
patrickdelaunay authored and Patrice Chotard committed Jun 16, 2023
1 parent 6bdef5b commit 7b802e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/arm/mach-stm32mp/bsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7b802e1

Please sign in to comment.