]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/rockchip: cleanup fb when drm_gem_fb_afbc_init failed
authorAndy Yan <andy.yan@rock-chips.com>
Fri, 9 May 2025 03:15:59 +0000 (11:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:38:36 +0000 (16:38 +0200)
[ Upstream commit 099593a28138b48feea5be8ce700e5bc4565e31d ]

In the function drm_gem_fb_init_with_funcs, the framebuffer (fb)
and its corresponding object ID have already been registered.

So we need to cleanup the drm framebuffer if the subsequent
execution of drm_gem_fb_afbc_init fails.

Directly call drm_framebuffer_put to ensure that all fb related
resources are cleanup.

Fixes: 7707f7227f09 ("drm/rockchip: Add support for afbc")
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20250509031607.2542187-1-andyshrk@163.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/rockchip/rockchip_drm_fb.c

index dcc1f07632c3a14d90d86ac6a00368b0ea799775..5829ee061c61bbc7ec8495b8aa910f71c94b9847 100644 (file)
@@ -52,16 +52,9 @@ rockchip_fb_create(struct drm_device *dev, struct drm_file *file,
        }
 
        if (drm_is_afbc(mode_cmd->modifier[0])) {
-               int ret, i;
-
                ret = drm_gem_fb_afbc_init(dev, mode_cmd, afbc_fb);
                if (ret) {
-                       struct drm_gem_object **obj = afbc_fb->base.obj;
-
-                       for (i = 0; i < info->num_planes; ++i)
-                               drm_gem_object_put(obj[i]);
-
-                       kfree(afbc_fb);
+                       drm_framebuffer_put(&afbc_fb->base);
                        return ERR_PTR(ret);
                }
        }