The firmware reference obtained via rpi_firmware_get() is leaked when
aperture_remove_all_conflicting_devices() fails, as the error label
returns without putting it. This happens before the firmware is
consumed and put further down in the function.

Put the firmware reference before jumping to err.

Fixes: c406ad5e4a85 ("drm/vc4: Notify the firmware when DRM is in charge")
Cc: [email protected]
Signed-off-by: Wentao Liang <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index a14ecb769461..7953d4f781d8 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -362,8 +362,11 @@ static int vc4_drm_bind(struct device *dev)
        }
 
        ret = aperture_remove_all_conflicting_devices(driver->name);
-       if (ret)
+       if (ret) {
+               if (firmware)
+                       rpi_firmware_put(firmware);
                goto err;
+       }
 
        if (firmware) {
                ret = rpi_firmware_property(firmware,
-- 
2.34.1

Reply via email to