Skip to contentSkip to conversation

drm/amdgpu: fix potential resource leak warning

PATCH In review Tim Huang 2 participants 2 messages Apr 25, 2024

Subsystems (2)
lore
Share & tools
lore

Tim Huang

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix potential resource leak warning

From: Tim Huang <[email protected]>

Clear resource leak warning that when the prepare fails, the allocated amdgpu job object will never be released.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +5 -0
index 66e8a016126b..9b748d7058b5 100644
@@ -102,6 +102,11 @@ static int amdgpu_vm_sdma_prepare(struct amdgpu_vm_update_params *p,
 	if (!r)
 		r = amdgpu_sync_push_to_job(&sync, p->job);
 	amdgpu_sync_free(&sync);
+
+	if (r) {
+		p->num_dw_left = 0;
+		amdgpu_job_free(p->job);
+	}
 	return r;
 }
 
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 25.04.24 um 05:33 schrieb Tim Huang:

Quoted 6 lines

From: Tim Huang <[email protected]>

Clear resource leak warning that when the prepare fails, the allocated amdgpu job object will never be released.

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +5 -0
index 66e8a016126b..9b748d7058b5 100644
@@ -102,6 +102,11 @@ static int amdgpu_vm_sdma_prepare(struct amdgpu_vm_update_params *p,
  	if (!r)
  		r = amdgpu_sync_push_to_job(&sync, p->job);
  	amdgpu_sync_free(&sync);
+
+	if (r) {
+		p->num_dw_left = 0;
+		amdgpu_job_free(p->job);
+	}
  	return r;
  }