drm/amd/display: Fix memory leak in dm_set_writeback()
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Fri, 8 Dec 2023 09:58:24 +0000 (01:58 -0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 13 Dec 2023 20:09:55 +0000 (15:09 -0500)
'wb_info' needs to be freed on error paths or it would leak the memory.

Smatch pointed this out.

Fixes: c81e13b929df ("drm/amd/display: Hande writeback request from userspace")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index e819d05755b3f47de247fac4abb3877641cbcf67..6efa0c1bba9d2622c04ed3e122fe4d7964ef4ec5 100644 (file)
@@ -8879,12 +8879,14 @@ static void dm_set_writeback(struct amdgpu_display_manager *dm,
        acrtc = to_amdgpu_crtc(wb_conn->encoder.crtc);
        if (!acrtc) {
                DRM_ERROR("no amdgpu_crtc found\n");
+               kfree(wb_info);
                return;
        }
 
        afb = to_amdgpu_framebuffer(new_con_state->writeback_job->fb);
        if (!afb) {
                DRM_ERROR("No amdgpu_framebuffer found\n");
+               kfree(wb_info);
                return;
        }