Skip to content

Commit

Permalink
drm/amdgpu: Fix memory leak
Browse files Browse the repository at this point in the history
drm_gem_object_put() should be paired with drm_gem_object_lookup().

All gem objs are saved in fb->base.obj[]. Need put the old first before
assign a new obj.

Trigger VRAM leak by running command below
$ service gdm restart

Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
xinhui pan authored and Alex Deucher committed Mar 24, 2021
1 parent 0303e1b commit 79fcd44
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,9 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
}

for (i = 1; i < rfb->base.format->num_planes; ++i) {
drm_gem_object_get(rfb->base.obj[0]);
drm_gem_object_put(rfb->base.obj[i]);
rfb->base.obj[i] = rfb->base.obj[0];
drm_gem_object_get(rfb->base.obj[i]);
}

return 0;
Expand Down Expand Up @@ -1002,6 +1003,7 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
return ERR_PTR(ret);
}

drm_gem_object_put(obj);
return &amdgpu_fb->base;
}

Expand Down

0 comments on commit 79fcd44

Please sign in to comment.