Re: [PATCH] media: imagination: Release m2m device on probe failure
From: Thakkar, Devarsh
Date: Thu Nov 05 2026 - 09:29:08 EST
Hi Liang,
Thanks for the patch.
On 03/11/26 15:16, Wentao Liang wrote:
> e5010_probe() initializes the mem2mem device after registering the v4l2
> device. When mapping the "core" or "mmu" register region, requesting the
> IRQ or getting the clock fails, the error path jumps to the
> fail_after_v4l2_register label, which only unregisters the v4l2 device.
> The v4l2_m2m_dev allocated by v4l2_m2m_init() is not released, so it
> leaks on these probe failures.
>
> Release the m2m device from that label as well, so that every error path
> taken after v4l2_m2m_init() succeeds frees it. v4l2_m2m_release() accepts
> a NULL pointer, so the v4l2_m2m_init() failure path is unaffected.
>
> Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
This is fixed by already posted patch [0] and series is under review, so
would prefer to take from there.
[0]: https://lore.kernel.org/all/20261023144618.1652390-2-b-brnich@xxxxxx/
Regards
Devarsh> ---
> drivers/media/platform/imagination/e5010-jpeg-enc.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
> index 420cb8bfdb12..49943bd604da 100644
> --- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
> +++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
> @@ -1104,7 +1104,7 @@ static int e5010_probe(struct platform_device *pdev)
> ret = video_register_device(e5010->vdev, VFL_TYPE_VIDEO, 0);
> if (ret) {
> dev_err_probe(dev, ret, "failed to register video device\n");
> - goto fail_after_video_register_device;
> + goto fail_after_v4l2_register;
> }
>
> v4l2_info(&e5010->v4l2_dev, "Device registered as /dev/video%d\n",
> @@ -1112,9 +1112,8 @@ static int e5010_probe(struct platform_device *pdev)
>
> return 0;
>
> -fail_after_video_register_device:
> - v4l2_m2m_release(e5010->m2m_dev);
> fail_after_v4l2_register:
> + v4l2_m2m_release(e5010->m2m_dev);
> v4l2_device_unregister(&e5010->v4l2_dev);
> fail_after_video_device_alloc:
> video_device_release(e5010->vdev);