Re: [PATCH] media: imagination: e5010: release m2m device on probe failure

From: Nicolas Dufresne

Date: Mon Sep 28 2026 - 15:33:32 EST


Hi,

sorry for the long delay, finally getting to this one, comment below...

Le samedi 25 avril 2026 à 01:58 +0900, 박명훈 a écrit :
> From: Myeonghun Pak <mhun512@xxxxxxxxx>
>
> The probe path allocates the mem2mem device with v4l2_m2m_init(),
> but several later failures jump directly to the v4l2_device_unregister()
> unwind path. Since the driver core does not call .remove() after a failed
> probe, those paths leak the m2m device.
>
> Route post-v4l2_m2m_init() failures through the existing m2m release step
> before unregistering the v4l2 device.
>
> Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
> ---
> drivers/media/platform/imagination/e5010-jpeg-enc.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
> index 42ad9ee399..4c250e2275 100644
> --- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
> +++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
> @@ -1072,14 +1072,14 @@ static int e5010_probe(struct platform_device *pdev)
> if (IS_ERR(e5010->core_base)) {
> ret = PTR_ERR(e5010->core_base);
> dev_err_probe(dev, ret, "Missing 'core' resources area\n");
> - goto fail_after_v4l2_register;
> + goto fail_after_m2m_init;
> }
>
> e5010->mmu_base = devm_platform_ioremap_resource_byname(pdev, "mmu");
> if (IS_ERR(e5010->mmu_base)) {
> ret = PTR_ERR(e5010->mmu_base);
> dev_err_probe(dev, ret, "Missing 'mmu' resources area\n");
> - goto fail_after_v4l2_register;
> + goto fail_after_m2m_init;
> }
>
> e5010->last_context_run = NULL;
> @@ -1089,14 +1089,14 @@ static int e5010_probe(struct platform_device *pdev)
> E5010_MODULE_NAME, e5010);
> if (ret) {
> dev_err_probe(dev, ret, "failed to register IRQ %d\n", irq);
> - goto fail_after_v4l2_register;
> + goto fail_after_m2m_init;
> }
>
> e5010->clk = devm_clk_get(dev, NULL);
> if (IS_ERR(e5010->clk)) {
> ret = PTR_ERR(e5010->clk);
> dev_err_probe(dev, ret, "failed to get clock\n");
> - goto fail_after_v4l2_register;
> + goto fail_after_m2m_init;
> }
>
> pm_runtime_enable(dev);
> @@ -1113,6 +1113,7 @@ static int e5010_probe(struct platform_device *pdev)
> return 0;
>
> fail_after_video_register_device:
> +fail_after_m2m_init:

Can't you simply use fail_after_video_register_device label ?

Nicolas

> v4l2_m2m_release(e5010->m2m_dev);
> fail_after_v4l2_register:
> v4l2_device_unregister(&e5010->v4l2_dev);

Attachment: signature.asc
Description: This is a digitally signed message part