VKMS planes are allocated with kzalloc_obj(), but both the plane
destroy callback and the output initialization error path only call
drm_plane_cleanup().

Add amdgpu_vkms_plane_fini() to clean up the DRM resources and free
the plane structure. Use it as the plane destroy callback and in the
output initialization error path.

Fixes: 84ec374bd580 ("drm/amdgpu: create amdgpu_vkms (v4)")
Signed-off-by: Haoxiang Li <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index 5c5fdbec93c2..a511322c1c02 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -140,10 +140,16 @@ static const struct drm_connector_helper_funcs 
amdgpu_vkms_conn_helper_funcs = {
        .get_modes    = amdgpu_vkms_conn_get_modes,
 };
 
+static void amdgpu_vkms_plane_fini(struct drm_plane *plane)
+{
+       drm_plane_cleanup(plane);
+       kfree(plane);
+}
+
 static const struct drm_plane_funcs amdgpu_vkms_plane_funcs = {
        .update_plane           = drm_atomic_helper_update_plane,
        .disable_plane          = drm_atomic_helper_disable_plane,
-       .destroy                = drm_plane_cleanup,
+       .destroy                = amdgpu_vkms_plane_fini,
        .atomic_create_state = drm_atomic_helper_plane_create_state,
        .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
        .atomic_destroy_state   = drm_atomic_helper_plane_destroy_state,
@@ -375,7 +381,7 @@ static int amdgpu_vkms_output_init(struct drm_device *dev, 
struct
        drm_crtc_cleanup(crtc);
 
 err_crtc:
-       drm_plane_cleanup(primary);
+       amdgpu_vkms_plane_fini(primary);
 
        return ret;
 }
-- 
2.25.1

Reply via email to