Message ID | 20231208095825.1291730-1-harshit.m.mogalapalli@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/amd/display: Fix memory leak in dm_set_writeback() | expand |
Thanks for catching this. Reviewed-by: Alex Hung <alex.hung@amd.com> On 2023-12-08 02:58, Harshit Mogalapalli wrote: > '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> > --- > This is based on static analysis and only compile tested > --- > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index afdcc43ea06c..333995f70239 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -8871,12 +8871,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; > } >
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index afdcc43ea06c..333995f70239 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8871,12 +8871,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; }
'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> --- This is based on static analysis and only compile tested --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++ 1 file changed, 2 insertions(+)