From: Pankaj Gupta <pankaj.gupta@nxp.com>
To: linux-kernel@vger.kernel.org
Cc: imx@lists.linux.dev, frank.li@nxp.com,
Pankaj Gupta <pankaj.gupta@nxp.com>,
Dan Carpenter <error27@gmail.com>
Subject: [PATCH -next] firmware: imx: Add missing return in error path to prevent use-after-free.
Date: Thu, 28 May 2026 14:44:46 +0530 [thread overview]
Message-ID: <20260528091446.3331006-1-pankaj.gupta@nxp.com> (raw)
After freeing dev_ctx and setting *new_dev_ctx to NULL, the function
continues execution and dereferences dev_ctx, leading to a potential
use-after-free. Return immediately to avoid accessing freed memory.
This appears to have been lost during merge of the original fix.
Fixes: 3ae9dcce8400 ("firmware: drivers: imx: adds miscdev")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
drivers/firmware/imx/se_ctrl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c
index 9327d47e4312..4914d3b6bf0b 100644
--- a/drivers/firmware/imx/se_ctrl.c
+++ b/drivers/firmware/imx/se_ctrl.c
@@ -486,6 +486,8 @@ static int init_device_context(struct se_if_priv *priv, int ch_id,
kfree(dev_ctx->devname);
kfree(dev_ctx);
*new_dev_ctx = NULL;
+
+ return ret;
}
list_add_tail(&dev_ctx->link, &priv->dev_ctx_list);
--
2.43.0
next reply other threads:[~2026-05-28 9:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 9:14 Pankaj Gupta [this message]
2026-05-28 10:01 ` Dan Carpenter
2026-06-01 21:20 ` Frank.Li
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=20260528091446.3331006-1-pankaj.gupta@nxp.com \
--to=pankaj.gupta@nxp.com \
--cc=error27@gmail.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®