Skip to contentSkip to conversation

drm/amd/amdgpu: fix refcount leak

PATCH In review Jingwen Chen 3 participants 3 messages May 17, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: fix refcount leak

[Why]
the gem object rfb->base.obj[0] is get according to num_planes in amdgpufb_create, but is not put according to num_planes

[How]
put rfb->base.obj[0] in amdgpu_fbdev_destroy according to num_planes

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +3 -0
index 4f10c4529840..09b048647523 100644
@@ -288,10 +288,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
 static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
 {
 	struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
+	int i;
 
 	drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
 	if (rfb->base.obj[0]) {
+		for (i = 0; i < rfb->base.format->num_planes; i++)
+			drm_gem_object_put(rfb->base.obj[0]);
 		amdgpufb_destroy_pinned_object(rfb->base.obj[0]);
 		rfb->base.obj[0] = NULL;
 		drm_framebuffer_unregister_private(&rfb->base);
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v1 1/1
#1 lore raw

Am 17.05.21 um 10:26 schrieb Jingwen Chen:

Quoted 8 lines

[Why]
the gem object rfb->base.obj[0] is get according to num_planes in amdgpufb_create, but is not put according to num_planes

[How]
put rfb->base.obj[0] in amdgpu_fbdev_destroy according to num_planes

Looks sane to me, but Alex might want to take a look as well.

Quoted 12 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +0 -0
index 4f10c4529840..09b048647523 100644
@@ -288,10 +288,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
  static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
  {
  	struct amdgpu_framebuffer *rfb = &rfbdev->rfb;

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create(struct drm_fb_helper *helper, · line 300

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +3 -0
+	int i;
 
  	drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
  	if (rfb->base.obj[0]) {
+		for (i = 0; i < rfb->base.format->num_planes; i++)
+			drm_gem_object_put(rfb->base.obj[0]);
  		amdgpufb_destroy_pinned_object(rfb->base.obj[0]);
  		rfb->base.obj[0] = NULL;
  		drm_framebuffer_unregister_private(&rfb->base);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#2 lore raw
Quoted 6 lines · Christian König

Am 17.05.21 um 10:26 schrieb Jingwen Chen:

Quoted 4 lines

[Why]
the gem object rfb->base.obj[0] is get according to num_planes in amdgpufb_create, but is not put according to num_planes

Quoted 8 lines
Quoted 4 lines

[How]
put rfb->base.obj[0] in amdgpu_fbdev_destroy according to num_planes

Looks sane to me, but Alex might want to take a look as well.

Looks good to me as well.

Quoted 17 lines
Quoted 17 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -0
index 4f10c4529840..09b048647523 100644
@@ -288,10 +288,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
  static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
  {
      struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
+     int i;
 
      drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create(struct drm_fb_helper *helper, · line 300

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -0
      if (rfb->base.obj[0]) {
+             for (i = 0; i < rfb->base.format->num_planes; i++)
+                     drm_gem_object_put(rfb->base.obj[0]);
              amdgpufb_destroy_pinned_object(rfb->base.obj[0]);
              rfb->base.obj[0] = NULL;
              drm_framebuffer_unregister_private(&rfb->base);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx