Skip to contentSkip to conversation

drm/amdgpu: release allocated memory

PATCH NAK Navid Emamdoost 4 participants 4 messages Sep 20, 2019 – Sep 23, 2019 2 messages not in the archive

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

PATCH 1/1 drm/amdgpu: release allocated memory

In amdgpu_vmid_grab_idle, fences is being leaked in one execution path. The missing kfree was added.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1 -0
index 57b3d8a9bef3..9063cd36fa94 100644
@@ -244,6 +244,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
 		r = amdgpu_sync_fence(adev, sync, &array->base, false);
 		dma_fence_put(ring->vmid_wait);
 		ring->vmid_wait = &array->base;
+		kfree(fences);
 		return r;
 	}
 	kfree(fences);
Signature · 1 line
2.17.1
maintainer NAK
#1 lore raw

Am 21.09.19 um 00:49 schrieb Navid Emamdoost:

Quoted 2 lines

In amdgpu_vmid_grab_idle, fences is being leaked in one execution path. The missing kfree was added.

NAK, the array is freed by the dma_fence_array.  This is a double free.

Regards,
Christian.

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1 -0
index 57b3d8a9bef3..9063cd36fa94 100644
@@ -244,6 +244,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
  		r = amdgpu_sync_fence(adev, sync, &array->base, false);
  		dma_fence_put(ring->vmid_wait);
  		ring->vmid_wait = &array->base;
+		kfree(fences);
  		return r;
  	}
  	kfree(fences);

A message that is not in the archive (sent off-list or not yet received): 06d1d086-0628-829b-766f-e1f614fab909-5C7GfCeVMHo@public.gmane.org

#3 lore raw

Maybe add a comment here in the code to avoid confusion in the future.

Alex
________________________________
From: Koenig, Christian <[email protected]>
Sent: Saturday, September 21, 2019 7:32 AM
To: Navid Emamdoost <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Deucher, Alexander <[email protected]>; Zhou, David(ChunMing) <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <daniel-/[email protected]>; Sam Ravnborg <[email protected]>; Rex Zhu <[email protected]>; [email protected] <[email protected]>; [email protected] <dri-devel-PD4FTy7X32lNgt0PjOBp9/[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: release allocated memory

Am 21.09.19 um 00:49 schrieb Navid Emamdoost:

Quoted 2 lines

In amdgpu_vmid_grab_idle, fences is being leaked in one execution path. The missing kfree was added.

NAK, the array is freed by the dma_fence_array. This is a double free.

Regards,
Christian.

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0 -0
index 57b3d8a9bef3..9063cd36fa94 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm, · line 250

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1 -0
@@ -244,6 +244,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
               r = amdgpu_sync_fence(adev, sync, &array->base, false);
               dma_fence_put(ring->vmid_wait);
               ring->vmid_wait = &array->base;
+             kfree(fences);
               return r;
       }
       kfree(fences);

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

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1809C096DD42018B33EDFC4FF7850-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#5 lore raw

Yeah, we already documented the dma_fence_array() behavior on that function.

But having another comment here would probably be a good idea.

Christian.

Am 23.09.19 um 14:35 schrieb Deucher, Alexander:
Maybe add a comment here in the code to avoid confusion in the future.

Alex
________________________________
From: Koenig, Christian <[email protected]><mailto:[email protected]>
Sent: Saturday, September 21, 2019 7:32 AM
To: Navid Emamdoost <[email protected]><mailto:[email protected]>
Cc: [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>; Deucher, Alexander <[email protected]><mailto:[email protected]>; Zhou, David(ChunMing) <[email protected]><mailto:[email protected]>; David Airlie <[email protected]><mailto:[email protected]>; Daniel Vetter <[email protected]><mailto:[email protected]>; Sam Ravnborg <[email protected]><mailto:[email protected]>; Rex Zhu <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>
Subject: Re: [PATCH] drm/amdgpu: release allocated memory

Am 21.09.19 um 00:49 schrieb Navid Emamdoost:

Quoted 2 lines

In amdgpu_vmid_grab_idle, fences is being leaked in one execution path. The missing kfree was added.

NAK, the array is freed by the dma_fence_array. This is a double free.

Regards,
Christian.

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0 -0
index 57b3d8a9bef3..9063cd36fa94 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm, · line 250

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1 -0
@@ -244,6 +244,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
               r = amdgpu_sync_fence(adev, sync, &array->base, false);
               dma_fence_put(ring->vmid_wait);
               ring->vmid_wait = &array->base;
+             kfree(fences);
               return r;
       }
       kfree(fences);

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