public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: trix@redhat.com, airlied@redhat.com, airlied@linux.ie,
	daniel@ffwll.ch, nathan@kernel.org, ndesaulniers@google.com,
	maxime@cerno.tech
Cc: llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ast: fix using freed memory
Date: Thu, 10 Feb 2022 19:55:49 +0100	[thread overview]
Message-ID: <5df2f9bb-9181-56da-ea85-06af7ea8704a@suse.de> (raw)
In-Reply-To: <20220203152305.1846862-1-trix@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1795 bytes --]

Hi

Am 03.02.22 um 16:23 schrieb trix@redhat.com:
> From: Tom Rix <trix@redhat.com>
> 
> clang static analysis reports this problem
> ast_mode.c:1235:3: warning: Use of memory after it is freed
>    drm_connector_update_edid_property(&ast_connector->base, edid);
>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The second condition on
> 
>    if (!flags && ast_connector->i2c)
> 
> Means that the edid is not always set.  If the previous block
> fails the freed edid value will be used.  So set edid to NULL
> after freeing.

Thanks for your patch. We have meanwhile merges a change that replaces 
the code entirely.

Best regards
Thomas

> 
> Fixes: 55dc449a7c60 ("drm/ast: Handle failed I2C initialization gracefully")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>   drivers/gpu/drm/ast/ast_mode.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index ab52efb15670e..9131dc8a1a2fc 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1224,10 +1224,12 @@ static int ast_get_modes(struct drm_connector *connector)
>   			return -ENOMEM;
>   
>   		flags = ast_dp501_read_edid(connector->dev, (u8 *)edid);
> -		if (flags)
> +		if (flags) {
>   			ast->dp501_maxclk = ast_get_dp501_max_clk(connector->dev);
> -		else
> +		} else {
>   			kfree(edid);
> +			edid = NULL;
> +		}
>   	}
>   	if (!flags && ast_connector->i2c)
>   		edid = drm_get_edid(connector, &ast_connector->i2c->adapter);

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

      parent reply	other threads:[~2022-02-10 18:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 15:23 [PATCH] drm/ast: fix using freed memory trix
2022-02-07 19:26 ` Nick Desaulniers
2022-02-10 18:55 ` Thomas Zimmermann [this message]

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=5df2f9bb-9181-56da-ea85-06af7ea8704a@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=maxime@cerno.tech \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox