From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
To: mirela.rabulea@nxp.com, mchehab@kernel.org, Frank.Li@nxp.com,
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de, festevam@gmail.com,
linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org
Subject: [PATCH] media: imx-jpeg: convert kzalloc() to devm_kzalloc()
Date: Sun, 8 Mar 2026 02:34:04 +0530 [thread overview]
Message-ID: <20260307210404.1428894-1-sanjayembedded@gmail.com> (raw)
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
The driver allcoates memory using kzalloc() and frees it in the relase
path. since the allocated memory is tied to the lifetime of the device,
devm_kzalloc() can be used instead.
Using device-managed allocation simplifies the error handling paths and
remove the need for manual cleanup.
No functional change intended.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index b558700d1d96..bd4b5f08a85c 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -2200,14 +2200,12 @@ static int mxc_jpeg_open(struct file *file)
struct mxc_jpeg_ctx *ctx;
int ret = 0;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
- if (mutex_lock_interruptible(&mxc_jpeg->lock)) {
- ret = -ERESTARTSYS;
- goto free;
- }
+ if (mutex_lock_interruptible(&mxc_jpeg->lock))
+ return -ERESTARTSYS;
v4l2_fh_init(&ctx->fh, mxc_vfd);
v4l2_fh_add(&ctx->fh, file);
@@ -2246,8 +2244,6 @@ static int mxc_jpeg_open(struct file *file)
v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&mxc_jpeg->lock);
-free:
- kfree(ctx);
return ret;
}
@@ -2754,7 +2750,6 @@ static int mxc_jpeg_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
- kfree(ctx);
mutex_unlock(&mxc_jpeg->lock);
return 0;
--
2.34.1
next reply other threads:[~2026-03-07 21:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 21:04 Sanjay Chitroda [this message]
2026-03-09 15:54 ` [PATCH] media: imx-jpeg: convert kzalloc() to devm_kzalloc() Frank Li
2026-03-10 2:59 ` Sanjay Chitroda
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=20260307210404.1428894-1-sanjayembedded@gmail.com \
--to=sanjayembeddedse@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mirela.rabulea@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=skhan@linuxfoundation.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