Subject: [PATCH next] firmware: imx: fix use after free in init_device_context()

From: Dan Carpenter <[email-masked]>
Date: Tue, 19 May 2026 09:13:34 +0300

Add a missing return statement on the error path.  Otherwise we have a
use after free when it dereferences "dev_ctx" on the next line.

Fixes: 63536a73a3bb ("firmware: drivers: imx: adds miscdev")
Signed-off-by: Dan Carpenter <[email-masked]>
---
This was in the original fix but I guess there was a merge problem.
https://lore.kernel.org/all/[email-masked]/

 drivers/firmware/imx/se_ctrl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c
index 9327d47e4312..010af8221dfe 100644
--- a/drivers/firmware/imx/se_ctrl.c
+++ b/drivers/firmware/imx/se_ctrl.c
@@ -486,6 +486,7 @@ 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.53.0