drm/rockchip: vop: 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: I51af5ea1fb4151db07a926f84e3cecaa5a7dab95
This commit is contained in:
Sandy Huang
2024-01-19 10:26:32 +08:00
committed by Huang Jiachai
parent 5539d6bb37
commit dd013b9938

View File

@@ -2477,13 +2477,15 @@ static void vop_plane_destroy(struct drm_plane *plane)
static void vop_atomic_plane_reset(struct drm_plane *plane)
{
struct vop_plane_state *vop_plane_state =
to_vop_plane_state(plane->state);
struct vop_plane_state *vop_plane_state;
struct vop_win *win = to_vop_win(plane);
if (plane->state && plane->state->fb)
if (plane->state) {
__drm_atomic_helper_plane_destroy_state(plane->state);
kfree(vop_plane_state);
vop_plane_state = to_vop_plane_state(plane->state);
kfree(vop_plane_state);
plane->state = NULL;
}
vop_plane_state = kzalloc(sizeof(*vop_plane_state), GFP_KERNEL);
if (!vop_plane_state)
return;