All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: tzimmermann@suse.de
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] drm/ast: Handle failed I2C initialization gracefully
Date: Thu, 6 Jan 2022 13:19:46 +0300	[thread overview]
Message-ID: <20220106101946.GA25857@kili> (raw)

Hello Thomas Zimmermann,

The patch 55dc449a7c60: "drm/ast: Handle failed I2C initialization
gracefully" from Dec 6, 2021, leads to the following Smatch static
checker warning:

	drivers/gpu/drm/ast/ast_mode.c:1232 ast_get_modes()
	warn: passing freed memory 'edid'

drivers/gpu/drm/ast/ast_mode.c
    1209 static int ast_get_modes(struct drm_connector *connector)
    1210 {
    1211         struct ast_connector *ast_connector = to_ast_connector(connector);
    1212         struct ast_private *ast = to_ast_private(connector->dev);
    1213         struct edid *edid = NULL;
    1214         bool flags = false;
    1215         int ret;
    1216 
    1217         if (ast->tx_chip_type == AST_TX_DP501) {
    1218                 ast->dp501_maxclk = 0xff;
    1219                 edid = kmalloc(128, GFP_KERNEL);
    1220                 if (!edid)
    1221                         return -ENOMEM;
    1222 
    1223                 flags = ast_dp501_read_edid(connector->dev, (u8 *)edid);
    1224                 if (flags)
    1225                         ast->dp501_maxclk = ast_get_dp501_max_clk(connector->dev);
    1226                 else
    1227                         kfree(edid);

kfree

    1228         }
    1229         if (!flags && ast_connector->i2c)
    1230                 edid = drm_get_edid(connector, &ast_connector->i2c->adapter);

If "!flags" is true but "ast_connector->i2c" is false

    1231         if (edid) {
--> 1232                 drm_connector_update_edid_property(&ast_connector->base, edid);

Then perhaps "edid" is free here.

    1233                 ret = drm_add_edid_modes(connector, edid);
    1234                 kfree(edid);
    1235                 return ret;
    1236         }
    1237         drm_connector_update_edid_property(&ast_connector->base, NULL);
    1238         return 0;
    1239 }

regards,
dan carpenter

                 reply	other threads:[~2022-01-06 10:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220106101946.GA25857@kili \
    --to=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 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.