drm/amdgpu: fix memory leak in psp

Submitted by Qingqing.Wang@amd.com on March 28, 2017, 9:16 a.m.

Details

Message ID 1490692569-15452-1-git-send-email-Qingqing.Wang@amd.com
State New
Headers show
Series "drm/amdgpu: fix memory leak in psp" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Qingqing.Wang@amd.com March 28, 2017, 9:16 a.m.
Change-Id: I6bea247f41ea405d11c1d75ca97b789f6970b191
Signed-off-by: Ken Wang <Qingqing.Wang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 89d1d2f..4731015f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -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;
 

Comments

Am 28.03.2017 um 11:16 schrieb Ken Wang:
> Change-Id: I6bea247f41ea405d11c1d75ca97b789f6970b191
> Signed-off-by: Ken Wang <Qingqing.Wang@amd.com>

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 <christian.koenig@amd.com>.

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 12 ++++++++++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 89d1d2f..4731015f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -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;
>
On Tue, Mar 28, 2017 at 05:16:09PM +0800, Ken Wang wrote:
> Change-Id: I6bea247f41ea405d11c1d75ca97b789f6970b191
> Signed-off-by: Ken Wang <Qingqing.Wang@amd.com>

Reviewed-by: Huang Rui <ray.huang@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 89d1d2f..4731015f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -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;
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx