All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: carsten.haitzler@foss.arm.com, dri-devel@lists.freedesktop.org
Cc: liviu.dudau@arm.com, Carsten Haitzler <carsten.haitzler@arm.com>
Subject: Re: [PATCH] drm/komeda: Handle NULL pointer access code path in error case
Date: Fri, 27 Nov 2020 15:52:01 +0000	[thread overview]
Message-ID: <d815594f-e6b6-92bf-e674-73d90a447ad9@arm.com> (raw)
In-Reply-To: <20201127110054.133686-1-carsten.haitzler@foss.arm.com>

On 27/11/2020 11:00, carsten.haitzler@foss.arm.com wrote:
> From: Carsten Haitzler <carsten.haitzler@arm.com>
> 
> komeda_component_get_old_state() technically can return a NULL
> pointer. komeda_compiz_set_input() even warns when this happens, but
> then proceeeds to use that NULL pointer tocompare memory content there
> agains the new sate to see if it changed. In this case, it's better to
> assume that the input changed as there is no old state to compare
> against and thus assume the changes happen anyway.
> 
> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
> ---
>   drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> index 8f32ae7c25d0..e8b1e15312d8 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> @@ -707,7 +707,8 @@ komeda_compiz_set_input(struct komeda_compiz *compiz,
>   	WARN_ON(!old_st);
>   
>   	/* compare with old to check if this input has been changed */
> -	if (memcmp(&(to_compiz_st(old_st)->cins[idx]), cin, sizeof(*cin)))
> +	if (!old_st ||
> +	    memcmp(&(to_compiz_st(old_st)->cins[idx]), cin, sizeof(*cin)))
>   		c_st->changed_active_inputs |= BIT(idx);

Even better, you can move the WARN_ON into the if:

	if (WARN_ON(!old_st) || ...

Either way:

Reviewed-by: Steven Price <steven.price@arm.com>

Steve

>   
>   	komeda_component_add_input(c_st, &dflow->input, idx);
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-11-27 15:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 11:00 [PATCH] drm/komeda: Handle NULL pointer access code path in error case carsten.haitzler
2020-11-27 15:52 ` Steven Price [this message]
2020-11-27 22:58 ` Liviu Dudau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d815594f-e6b6-92bf-e674-73d90a447ad9@arm.com \
    --to=steven.price@arm.com \
    --cc=carsten.haitzler@arm.com \
    --cc=carsten.haitzler@foss.arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=liviu.dudau@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.