mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] firmware: imx: Add missing return in error path to prevent use-after-free.
@ 2026-05-28  9:14 Pankaj Gupta
  2026-05-28 10:01 ` Dan Carpenter
  2026-06-01 21:20 ` Frank.Li
  0 siblings, 2 replies; 3+ messages in thread
From: Pankaj Gupta @ 2026-05-28  9:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: imx, frank.li, Pankaj Gupta, Dan Carpenter

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-01 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-28  9:14 [PATCH -next] firmware: imx: Add missing return in error path to prevent use-after-free Pankaj Gupta
2026-05-28 10:01 ` Dan Carpenter
2026-06-01 21:20 ` Frank.Li

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®