From: Dan Carpenter <error27@gmail.com>
To: Pankaj Gupta <pankaj.gupta@nxp.com>
Cc: imx@lists.linux.dev
Subject: [bug report] firmware: drivers: imx: adds miscdev
Date: Thu, 7 May 2026 09:35:18 +0300 [thread overview]
Message-ID: <afwypVc5gq_QoF-h@stanley.mountain> (raw)
Hello Pankaj Gupta,
Commit 4de71839142b ("firmware: drivers: imx: adds miscdev") from Jan
22, 2026 (linux-next), leads to the following Smatch static checker
warning:
drivers/firmware/imx/se_ctrl.c:490 init_device_context()
warn: '&dev_ctx->link' not removed from list
drivers/firmware/imx/se_ctrl.c
461 static int init_device_context(struct se_if_priv *priv, int ch_id,
462 struct se_if_device_ctx **new_dev_ctx)
463 {
464 struct se_if_device_ctx *dev_ctx;
465 int ret = 0;
466
467 dev_ctx = kzalloc(sizeof(*dev_ctx), GFP_KERNEL);
468
469 if (!dev_ctx)
470 return -ENOMEM;
471
472 dev_ctx->devname = kasprintf(GFP_KERNEL, "%s0_ch%d",
473 get_se_if_name(priv->if_defs->se_if_type),
474 ch_id);
475 if (!dev_ctx->devname) {
476 kfree(dev_ctx);
477 return -ENOMEM;
478 }
479
480 mutex_init(&dev_ctx->fops_lock);
481 dev_ctx->priv = priv;
482 *new_dev_ctx = dev_ctx;
483
484 list_add_tail(&dev_ctx->link, &priv->dev_ctx_list);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This adds dev_ctx to the list
485 priv->active_devctx_count++;
486
487 ret = init_se_shared_mem(dev_ctx);
488 if (ret < 0) {
489 kfree(dev_ctx->devname);
--> 490 kfree(dev_ctx);
But it's still on the list when we free it so it leads to a use after
free.
491 *new_dev_ctx = NULL;
492 }
493
494 return ret;
495 }
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
next reply other threads:[~2026-05-07 6:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 6:35 Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-05-07 6:59 [bug report] firmware: drivers: imx: adds miscdev Dan Carpenter
2026-05-07 7:07 Dan Carpenter
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=afwypVc5gq_QoF-h@stanley.mountain \
--to=error27@gmail.com \
--cc=imx@lists.linux.dev \
--cc=pankaj.gupta@nxp.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