lkml.org 
[lkml]   [2026]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 3/4] media: imx8-isi: fix isi->pipes memory leak in probe and remove
From
Hi Laurent,

Thanks for the review

On 5/6/26 20:41, Laurent Pinchart wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> Hello Xiaolei,
>
> Thank you for the patch.
>
> On Wed, May 06, 2026 at 11:12:09AM +0800, Xiaolei Wang wrote:
>> mxc_isi_probe() allocates isi->pipes with kzalloc_objs() but never
>> frees it on any probe failure path or in mxc_isi_remove(), leaking
>> the allocation on every failed probe and every normal unbind.
>>
>> Fix this by switching from kzalloc_objs() to devm_kcalloc(), which
>> ties the allocation lifetime to the device and eliminates the need
>> for explicit kfree() in all error paths and in mxc_isi_remove().
> There's ongoing work to add a devm_kzalloc_objs(), to I'd rather not
> revert to kcalloc. If you want to fix this leak now without waiting for
> devm_kzalloc_objs(), I would prefer adding kfree() in error paths and in
> mxc_isi_remove().

Thanks for the suggestion. I agree that waiting for devm_kzalloc_objs()

is the reasonable approach.

thanks

xiaolei

>
>> Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
>> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
>> ---
>> drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> 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 2d639b789910..2b76fb9c18f6 100644
>> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
>> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
>> @@ -485,7 +485,8 @@ static int mxc_isi_probe(struct platform_device *pdev)
>>
>> isi->pdata = of_device_get_match_data(dev);
>>
>> - isi->pipes = kzalloc_objs(isi->pipes[0], isi->pdata->num_channels);
>> + isi->pipes = devm_kcalloc(dev, isi->pdata->num_channels,
>> + sizeof(*isi->pipes), GFP_KERNEL);
>> if (!isi->pipes)
>> return -ENOMEM;
>>
> --
> Regards,
>
> Laurent Pinchart

\
 
 \ /
  Last update: 2026-05-06 16:36    [W:0.094 / U:27.027 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog