]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: cedrus: Fix failure to clean up hardware on probe failure
authorSamuel Holland <samuel@sholland.org>
Mon, 6 Apr 2026 22:14:40 +0000 (01:14 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 4 May 2026 07:31:04 +0000 (09:31 +0200)
If V4L2 device fails to register, then SRAM still be claimed and as a
result driver will not be able to probe again.

 cedrus 1c0e000.video-codec: Failed to claim SRAM
 cedrus 1c0e000.video-codec: Failed to probe hardware
 cedrus 1c0e000.video-codec: probe with driver cedrus failed with error -16

cedrus_hw_remove undoes everything that was previously done by
cedrus_hw_probe, such as disabling runtime power management and
releasing the claimed SRAM and reserved memory region.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
Acked-by: Paul Kocialkowski <paulk@sys-base.io>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/staging/media/sunxi/cedrus/cedrus.c

index 1d2130f35fffcf7ff55012fa5e33486b7d6b375b..ee0e286add67d2223f81b42593c08311c7288413 100644 (file)
@@ -477,7 +477,7 @@ static int cedrus_probe(struct platform_device *pdev)
        ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
        if (ret) {
                dev_err(&pdev->dev, "Failed to register V4L2 device\n");
-               return ret;
+               goto err_hw;
        }
 
        vfd = &dev->vfd;
@@ -538,6 +538,8 @@ err_m2m:
        v4l2_m2m_release(dev->m2m_dev);
 err_v4l2:
        v4l2_device_unregister(&dev->v4l2_dev);
+err_hw:
+       cedrus_hw_remove(dev);
 
        return ret;
 }