From: trix@redhat.com
To: airlied@redhat.com, tzimmermann@suse.de, airlied@linux.ie,
daniel@ffwll.ch, nathan@kernel.org, ndesaulniers@google.com,
maxime@cerno.tech
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Tom Rix <trix@redhat.com>
Subject: [PATCH] drm/ast: fix using freed memory
Date: Thu, 3 Feb 2022 07:23:05 -0800 [thread overview]
Message-ID: <20220203152305.1846862-1-trix@redhat.com> (raw)
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.
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);
--
2.26.3
next reply other threads:[~2022-02-03 15:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 15:23 trix [this message]
2022-02-07 19:26 ` [PATCH] drm/ast: fix using freed memory Nick Desaulniers
2022-02-10 18:55 ` Thomas Zimmermann
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=20220203152305.1846862-1-trix@redhat.com \
--to=trix@redhat.com \
--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=tzimmermann@suse.de \
/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