From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-media@vger.kernel.org, linux-hardening@vger.kernel.org,
gustavoars@kernel.org, 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>,
"open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
<imx@lists.linux.dev>,
"moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: nxp: imx8-isi: remove kzalloc_objs
Date: Fri, 20 Mar 2026 00:09:01 +0200 [thread overview]
Message-ID: <20260319220901.GD950375@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260306044536.149204-1-rosenp@gmail.com>
On Thu, Mar 05, 2026 at 08:45:36PM -0800, Rosen Penev wrote:
> Use a flexible arraay member to combine allocations.
>
> It looks like pipes never gets freed anywhere. Meaning this effectively
> fixes a memory leak.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 11 ++++-------
> drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h | 3 ++-
> 2 files changed, 6 insertions(+), 8 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..657ffecc4d7e 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> @@ -459,25 +459,21 @@ 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);
I'd keep
isi->pdata = pdata;
here and not below.
> -
> - isi->pipes = kzalloc_objs(isi->pipes[0], isi->pdata->num_channels);
Wouldn't it be simpler to just replace this with devm_kcalloc() ?
isi->pipes = devm_kcalloc(dev, isi->pdata->num_channels,
sizeof(isi->pipes[0]), GFP_KERNEL);
No other change would be needed.
> - if (!isi->pipes)
> - return -ENOMEM;
> -
> isi->num_clks = devm_clk_bulk_get_all(dev, &isi->clks);
> if (isi->num_clks < 0)
> return dev_err_probe(dev, isi->num_clks, "Failed to get clocks\n");
> @@ -487,6 +483,7 @@ static int mxc_isi_probe(struct platform_device *pdev)
> return dev_err_probe(dev, PTR_ERR(isi->regs),
> "Failed to get ISI register map\n");
>
> + isi->pdata = pdata;
> if (isi->pdata->gasket_ops) {
> isi->gasket = syscon_regmap_lookup_by_phandle(dev->of_node,
> "fsl,blk-ctrl");
> 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;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-03-19 22:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 4:45 [PATCH] media: nxp: imx8-isi: remove kzalloc_objs Rosen Penev
2026-03-06 5:11 ` Frank Li
2026-03-06 6:19 ` Rosen Penev
2026-03-06 6:56 ` Marc Kleine-Budde
2026-03-06 6:59 ` Rosen Penev
2026-03-06 7:04 ` Marc Kleine-Budde
2026-03-19 22:09 ` Laurent Pinchart [this message]
2026-03-20 0:11 ` Rosen Penev
2026-03-20 0:57 ` Laurent Pinchart
2026-03-20 1:06 ` Rosen Penev
2026-03-20 10:16 ` Laurent Pinchart
2026-03-20 18:15 ` Kees Cook
2026-03-26 1:53 ` Rosen Penev
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=20260319220901.GD950375@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=gustavoars@kernel.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rosenp@gmail.com \
--cc=s.hauer@pengutronix.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