Skip to contentSkip to conversation

drm/amdgpu: fix memory leak in psp

PATCH In review Ken Wang 3 participants 3 messages Mar 28, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Ken Wang

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix memory leak in psp

Change-Id I6bea247f41ea405d11c1d75ca97b789f6970b191
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +10 -2
index 89d1d2f..4731015f 100644
@@ -132,6 +132,10 @@ psp_cmd_submit_buf(struct psp_context *psp,
 		msleep(1);
 	};
 
+	amdgpu_bo_free_kernel(&cmd_buf_bo,
+			      &cmd_buf_mc_addr,
+			      (void **)&cmd_buf_mem);
+
 	return ret;
 }
 
@@ -174,6 +178,8 @@ static int psp_tmr_init(struct psp_context *psp)
 	if (ret)
 		goto failed_mem;
 
+	kfree(cmd);
+
 	return 0;
 
 failed_mem:
@@ -241,6 +247,7 @@ static int psp_asd_load(struct psp_context *psp)
 
 	amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
 	amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
+	kfree(cmd);
 
 	return 0;
 
@@ -289,11 +296,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
 
 	ret = psp_tmr_init(psp);
 	if (ret)
-		goto failed;
+		goto failed_mem;
 
 	ret = psp_asd_load(psp);
 	if (ret)
-		goto failed;
+		goto failed_mem;
 
 	for (i = 0; i < adev->firmware.max_ucodes; i++) {
 		ucode = &adev->firmware.ucode[i];
@@ -322,6 +329,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
 
 	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
 			      &psp->fence_buf_mc_addr, &psp->fence_buf);
+	kfree(cmd);
 
 	return 0;
 
Signature · 6 lines
2.7.4

_______________________________________________
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): 1490692569-15452-1-git-send-email-Qingqing.Wang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 28.03.2017 um 11:16 schrieb Ken Wang:

Quoted 2 lines
Change-Id I6bea247f41ea405d11c1d75ca97b789f6970b191

I don't know the PSP code to well, but that looks correct to me on first glance.

Patch is Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Quoted 51 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -2
index 89d1d2f..4731015f 100644
@@ -132,6 +132,10 @@ psp_cmd_submit_buf(struct psp_context *psp,
  		msleep(1);
  	};
 
+	amdgpu_bo_free_kernel(&cmd_buf_bo,
+			      &cmd_buf_mc_addr,
+			      (void **)&cmd_buf_mem);
+
  	return ret;
  }
 
@@ -174,6 +178,8 @@ static int psp_tmr_init(struct psp_context *psp)
  	if (ret)
  		goto failed_mem;
 
+	kfree(cmd);
+
  	return 0;
 
  failed_mem:
@@ -241,6 +247,7 @@ static int psp_asd_load(struct psp_context *psp)
 
  	amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
  	amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
+	kfree(cmd);
 
  	return 0;
 
@@ -289,11 +296,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
 
  	ret = psp_tmr_init(psp);
  	if (ret)
-		goto failed;
+		goto failed_mem;
 
  	ret = psp_asd_load(psp);
  	if (ret)
-		goto failed;
+		goto failed_mem;
 
  	for (i = 0; i < adev->firmware.max_ucodes; i++) {
  		ucode = &adev->firmware.ucode[i];

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 335

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -0
@@ -322,6 +329,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
 
  	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
  			      &psp->fence_buf_mc_addr, &psp->fence_buf);
+	kfree(cmd);
 
  	return 0;
 

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

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · Ken Wang
Change-Id I6bea247f41ea405d11c1d75ca97b789f6970b191
Quoted 65 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +10 -2
index 89d1d2f..4731015f 100644
@@ -132,6 +132,10 @@ psp_cmd_submit_buf(struct psp_context *psp,
 		msleep(1);
 	};
 
+	amdgpu_bo_free_kernel(&cmd_buf_bo,
+			      &cmd_buf_mc_addr,
+			      (void **)&cmd_buf_mem);
+
 	return ret;
 }
 
@@ -174,6 +178,8 @@ static int psp_tmr_init(struct psp_context *psp)
 	if (ret)
 		goto failed_mem;
 
+	kfree(cmd);
+
 	return 0;
 
 failed_mem:
@@ -241,6 +247,7 @@ static int psp_asd_load(struct psp_context *psp)
 
 	amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
 	amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
+	kfree(cmd);
 
 	return 0;
 
@@ -289,11 +296,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
 
 	ret = psp_tmr_init(psp);
 	if (ret)
-		goto failed;
+		goto failed_mem;
 
 	ret = psp_asd_load(psp);
 	if (ret)
-		goto failed;
+		goto failed_mem;
 
 	for (i = 0; i < adev->firmware.max_ucodes; i++) {
 		ucode = &adev->firmware.ucode[i];
@@ -322,6 +329,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
 
 	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
 			      &psp->fence_buf_mc_addr, &psp->fence_buf);
+	kfree(cmd);
 
 	return 0;
 
Signature · 6 lines
2.7.4

_______________________________________________
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