[PATCH master] optee: check optee_verify_header argument for error pointers

Marco Felsch m.felsch at pengutronix.de
Thu Feb 29 03:08:46 PST 2024


On 24-02-29, Ahmad Fatoum wrote:
> optee_verify_header is called at two places with
> imx_scratch_get_optee_hdr() as argument, which returns an error pointer.
> 
> Check against that to avoid crashing in error cases.
> 
> Suggested-by: Marco Felsch <m.felsch at pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

Reviewed-by: Marco Felsch <m.felsch at pengutronix.de>

> ---
>  common/optee.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/optee.c b/common/optee.c
> index a8a43554e757..7fe93e441974 100644
> --- a/common/optee.c
> +++ b/common/optee.c
> @@ -10,7 +10,7 @@ static u64 optee_membase = U64_MAX;
>  
>  int optee_verify_header(const struct optee_header *hdr)
>  {
> -	if (!hdr)
> +	if (IS_ERR_OR_NULL(hdr))
>  		return -EINVAL;
>  
>  	if (hdr->magic != OPTEE_MAGIC) {
> -- 
> 2.39.2
> 
> 



More information about the barebox mailing list