From: Pankaj Gupta <pankaj.gupta@nxp.com>
To: linux-kernel@vger.kernel.org
Cc: frank.li@nxp.com, imx@lists.linux.dev,
Pankaj Gupta <pankaj.gupta@nxp.com>,
kernel test robot <lkp@intel.com>
Subject: [PATCH -next] firmware: imx: se_ctrl: fix init_device_context() error path
Date: Thu, 14 May 2026 14:34:57 +0530 [thread overview]
Message-ID: <20260514090457.2186933-1-pankaj.gupta@nxp.com> (raw)
init_device_context() adds dev_ctx to priv->dev_ctx_list before
init_se_shared_mem() succeeds. If init_se_shared_mem() fails, the code
frees dev_ctx but still leaves the list insertion and active count update
in the function flow.
Move the list insertion and active device context count update to the
success path only, and return immediately after cleanup on error.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605090441.GzJS1R6y-lkp@intel.com/
Fixes: 106ffe5d78ad ("firmware: imx: add driver for NXP EdgeLock Enclave")
Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
drivers/firmware/imx/se_ctrl.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c
index 1683b259864f..74786ebaaa89 100644
--- a/drivers/firmware/imx/se_ctrl.c
+++ b/drivers/firmware/imx/se_ctrl.c
@@ -481,16 +481,17 @@ static int init_device_context(struct se_if_priv *priv, int ch_id,
dev_ctx->priv = priv;
*new_dev_ctx = dev_ctx;
- list_add_tail(&dev_ctx->link, &priv->dev_ctx_list);
- priv->active_devctx_count++;
-
ret = init_se_shared_mem(dev_ctx);
if (ret < 0) {
kfree(dev_ctx->devname);
kfree(dev_ctx);
*new_dev_ctx = NULL;
+ return ret;
}
+ list_add_tail(&dev_ctx->link, &priv->dev_ctx_list);
+ priv->active_devctx_count++;
+
return ret;
}
--
2.43.0
next reply other threads:[~2026-05-14 9:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 9:04 Pankaj Gupta [this message]
2026-05-14 17:51 ` [PATCH -next] firmware: imx: se_ctrl: fix init_device_context() error path sashiko-bot
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=20260514090457.2186933-1-pankaj.gupta@nxp.com \
--to=pankaj.gupta@nxp.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.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