From: Rosen Penev <rosenp@gmail.com>
To: linux-media@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Dong Aisheng <aisheng.dong@nxp.com>,
Jacopo Mondi <jacopo@jmondi.org>,
Guoniu Zhou <guoniu.zhou@nxp.com>,
Stefan Riedmueller <s.riedmueller@phytec.de>,
imx@lists.linux.dev (open list:ARM/FREESCALE IMX / MXC ARM
ARCHITECTURE),
linux-arm-kernel@lists.infradead.org (moderated
list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCHv2] media: nxp: imx8-isi: remove kzalloc_objs
Date: Thu, 19 Mar 2026 17:19:43 -0700 [thread overview]
Message-ID: <20260320001943.19443-1-rosenp@gmail.com> (raw)
Use a flexible array member to combine allocations.
It looks like pipes never gets freed anywhere. Meaning this effectively
fixes a memory leak.
Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v2: add fixes tag, fix typo, and move pdata assignment to original
place.
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 10 ++++------
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h | 3 ++-
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
index 16392420903a..8d8ee1b3076b 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
@@ -459,24 +459,22 @@ static const struct dev_pm_ops mxc_isi_pm_ops = {
static int mxc_isi_probe(struct platform_device *pdev)
{
+ const struct mxc_isi_plat_data *pdata;
struct device *dev = &pdev->dev;
struct mxc_isi_dev *isi;
unsigned int dma_size;
unsigned int i;
int ret = 0;
- isi = devm_kzalloc(dev, sizeof(*isi), GFP_KERNEL);
+ pdata = of_device_get_match_data(dev);
+ isi = devm_kzalloc(dev, struct_size(isi, pipes, pdata->num_channels), GFP_KERNEL);
if (!isi)
return -ENOMEM;
isi->dev = dev;
platform_set_drvdata(pdev, isi);
- isi->pdata = of_device_get_match_data(dev);
-
- isi->pipes = kzalloc_objs(isi->pipes[0], isi->pdata->num_channels);
- if (!isi->pipes)
- return -ENOMEM;
+ isi->pdata = pdata;
isi->num_clks = devm_clk_bulk_get_all(dev, &isi->clks);
if (isi->num_clks < 0)
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
index 3cbd35305af0..99532efa4e41 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
@@ -286,7 +286,6 @@ struct mxc_isi_dev {
struct regmap *gasket;
struct mxc_isi_crossbar crossbar;
- struct mxc_isi_pipe *pipes;
struct mxc_isi_m2m m2m;
struct media_device media_dev;
@@ -294,6 +293,8 @@ struct mxc_isi_dev {
struct v4l2_async_notifier notifier;
struct dentry *debugfs_root;
+
+ struct mxc_isi_pipe pipes[];
};
extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
--
2.53.0
reply other threads:[~2026-03-20 0:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260320001943.19443-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=festevam@gmail.com \
--cc=guoniu.zhou@nxp.com \
--cc=imx@lists.linux.dev \
--cc=jacopo@jmondi.org \
--cc=kernel@pengutronix.de \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=s.riedmueller@phytec.de \
/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