All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix RAS memory leak in error case
@ 2020-06-02  5:49 Guchun Chen
  2020-06-02  6:03 ` Zhou1, Tao
  0 siblings, 1 reply; 2+ messages in thread
From: Guchun Chen @ 2020-06-02  5:49 UTC (permalink / raw)
  To: amd-gfx, Hawking.Zhang, Tao.Zhou1; +Cc: Guchun Chen

RAS context memory needs to freed in failure case.

Signed-off-by: Guchun Chen <guchun.chen@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 5c73f444eaef..79bb05d791bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -1881,9 +1881,8 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
 	amdgpu_ras_check_supported(adev, &con->hw_supported,
 			&con->supported);
 	if (!con->hw_supported) {
-		amdgpu_ras_set_context(adev, NULL);
-		kfree(con);
-		return 0;
+		r = 0;
+		goto err_out;
 	}
 
 	con->features = 0;
@@ -1894,29 +1893,31 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
 	if (adev->nbio.funcs->init_ras_controller_interrupt) {
 		r = adev->nbio.funcs->init_ras_controller_interrupt(adev);
 		if (r)
-			return r;
+			goto err_out;
 	}
 
 	if (adev->nbio.funcs->init_ras_err_event_athub_interrupt) {
 		r = adev->nbio.funcs->init_ras_err_event_athub_interrupt(adev);
 		if (r)
-			return r;
+			goto err_out;
 	}
 
 	amdgpu_ras_mask &= AMDGPU_RAS_BLOCK_MASK;
 
-	if (amdgpu_ras_fs_init(adev))
-		goto fs_out;
+	if (amdgpu_ras_fs_init(adev)) {
+		r = -EINVAL;
+		goto err_out;
+	}
 
 	dev_info(adev->dev, "RAS INFO: ras initialized successfully, "
 			"hardware ability[%x] ras_mask[%x]\n",
 			con->hw_supported, con->supported);
 	return 0;
-fs_out:
+err_out:
 	amdgpu_ras_set_context(adev, NULL);
 	kfree(con);
 
-	return -EINVAL;
+	return r;
 }
 
 /* helper function to handle common stuff in ip late init phase */
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/amdgpu: fix RAS memory leak in error case
  2020-06-02  5:49 [PATCH] drm/amdgpu: fix RAS memory leak in error case Guchun Chen
@ 2020-06-02  6:03 ` Zhou1, Tao
  0 siblings, 0 replies; 2+ messages in thread
From: Zhou1, Tao @ 2020-06-02  6:03 UTC (permalink / raw)
  To: Chen, Guchun, amd-gfx, Zhang, Hawking

[AMD Public Use]

Reviewed-by: Tao Zhou <tao.zhou1@amd.com>

> -----Original Message-----
> From: Chen, Guchun <Guchun.Chen@amd.com>
> Sent: 2020年6月2日 13:50
> To: amd-gfx@lists.freedesktop.org; Zhang, Hawking
> <Hawking.Zhang@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>
> Cc: Chen, Guchun <Guchun.Chen@amd.com>
> Subject: [PATCH] drm/amdgpu: fix RAS memory leak in error case
> 
> RAS context memory needs to freed in failure case.
> 
> Signed-off-by: Guchun Chen <guchun.chen@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> index 5c73f444eaef..79bb05d791bc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> @@ -1881,9 +1881,8 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
>  	amdgpu_ras_check_supported(adev, &con->hw_supported,
>  			&con->supported);
>  	if (!con->hw_supported) {
> -		amdgpu_ras_set_context(adev, NULL);
> -		kfree(con);
> -		return 0;
> +		r = 0;
> +		goto err_out;
>  	}
> 
>  	con->features = 0;
> @@ -1894,29 +1893,31 @@ int amdgpu_ras_init(struct amdgpu_device
> *adev)
>  	if (adev->nbio.funcs->init_ras_controller_interrupt) {
>  		r = adev->nbio.funcs->init_ras_controller_interrupt(adev);
>  		if (r)
> -			return r;
> +			goto err_out;
>  	}
> 
>  	if (adev->nbio.funcs->init_ras_err_event_athub_interrupt) {
>  		r = adev->nbio.funcs-
> >init_ras_err_event_athub_interrupt(adev);
>  		if (r)
> -			return r;
> +			goto err_out;
>  	}
> 
>  	amdgpu_ras_mask &= AMDGPU_RAS_BLOCK_MASK;
> 
> -	if (amdgpu_ras_fs_init(adev))
> -		goto fs_out;
> +	if (amdgpu_ras_fs_init(adev)) {
> +		r = -EINVAL;
> +		goto err_out;
> +	}
> 
>  	dev_info(adev->dev, "RAS INFO: ras initialized successfully, "
>  			"hardware ability[%x] ras_mask[%x]\n",
>  			con->hw_supported, con->supported);
>  	return 0;
> -fs_out:
> +err_out:
>  	amdgpu_ras_set_context(adev, NULL);
>  	kfree(con);
> 
> -	return -EINVAL;
> +	return r;
>  }
> 
>  /* helper function to handle common stuff in ip late init phase */
> --
> 2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-02  6:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  5:49 [PATCH] drm/amdgpu: fix RAS memory leak in error case Guchun Chen
2020-06-02  6:03 ` Zhou1, Tao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.