drm/rockchip: vop2: fix memleak when suspend and resume

kmemleak info after enable CONFIG_DEBUG_KMEMLEAK:

    unreferenced object 0xffffff80112dba00 (size 256):
      comm "modetest", pid 255, jiffies 4294879760 (age 122.330s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
        ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ................
      backtrace:
        [<0000000092315209>] __kmem_cache_alloc_node+0x1a0/0x248
        [<00000000d5355e57>] kmalloc_trace+0x48/0xf8
        [<00000000b9e2dd8f>] crtc_or_fake_commit.part.25+0x64/0xa8
        [<00000000c1d5c4e3>] drm_atomic_helper_setup_commit+0x9f8/0xae0
        [<0000000061ec52ff>] drm_atomic_helper_commit+0x68/0x1f0
        [<00000000bb9021c0>] drm_atomic_commit+0x154/0x1a8
        [<00000000ef746510>] drm_mode_obj_set_property_ioctl+0x2d0/0x5d0
        [<00000000f75e1783>] drm_ioctl_kernel+0x144/0x190
        [<00000000adad488c>] drm_ioctl+0x35c/0x600
        [<00000000c21ad072>] drm_compat_ioctl+0x144/0x158
        [<000000003c3b054c>] __arm64_compat_sys_ioctl+0xf4/0x170
        [<00000000954b018e>] invoke_syscall+0x60/0x178
        [<00000000d1ca1895>] el0_svc_common.constprop.2+0x164/0x1f8
        [<00000000cd485e29>] do_el0_svc_compat+0x34/0x58
        [<00000000eda6b1c7>] el0_svc_compat+0x14/0x40
        [<00000000ec48711e>] el0t_32_sync_handler+0xdc/0xf8

Signed-off-by: Sandy Huang <hjc@rock-chips.com>
Change-Id: I3de539959269808a3918a993cb3dcd26bb5e02ed
This commit is contained in:
Sandy Huang
2024-01-19 10:32:28 +08:00
committed by Huang Jiachai
parent dd013b9938
commit c260cfd73c

View File

@@ -6146,12 +6146,16 @@ static void vop2_plane_destroy(struct drm_plane *plane)
static void vop2_atomic_plane_reset(struct drm_plane *plane)
{
struct vop2_plane_state *vpstate = to_vop2_plane_state(plane->state);
struct vop2_plane_state *vpstate;
struct vop2_win *win = to_vop2_win(plane);
if (plane->state && plane->state->fb)
if (plane->state) {
__drm_atomic_helper_plane_destroy_state(plane->state);
kfree(vpstate);
vpstate = to_vop2_plane_state(plane->state);
kfree(vpstate);
plane->state = NULL;
}
vpstate = kzalloc(sizeof(*vpstate), GFP_KERNEL);
if (!vpstate)
return;