mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] optee: check optee_verify_header argument for error pointers
@ 2024-02-29  9:46 Ahmad Fatoum
  2024-02-29 11:08 ` Marco Felsch
  2024-03-01  9:20 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-02-29  9:46 UTC (permalink / raw)
  To: barebox; +Cc: Marco Felsch, Ahmad Fatoum

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@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master] optee: check optee_verify_header argument for error pointers
  2024-02-29  9:46 [PATCH master] optee: check optee_verify_header argument for error pointers Ahmad Fatoum
@ 2024-02-29 11:08 ` Marco Felsch
  2024-03-01  9:20 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Marco Felsch @ 2024-02-29 11:08 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

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@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Reviewed-by: Marco Felsch <m.felsch@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
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master] optee: check optee_verify_header argument for error pointers
  2024-02-29  9:46 [PATCH master] optee: check optee_verify_header argument for error pointers Ahmad Fatoum
  2024-02-29 11:08 ` Marco Felsch
@ 2024-03-01  9:20 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-03-01  9:20 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Marco Felsch


On Thu, 29 Feb 2024 10:46:56 +0100, 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.
> 
> 

Applied, thanks!

[1/1] optee: check optee_verify_header argument for error pointers
      https://git.pengutronix.de/cgit/barebox/commit/?id=231e81f8645c (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-01  9:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29  9:46 [PATCH master] optee: check optee_verify_header argument for error pointers Ahmad Fatoum
2024-02-29 11:08 ` Marco Felsch
2024-03-01  9:20 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox