linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/amdgpu: cleanup the code style a bit
@ 2021-11-15  7:07 Bernard Zhao
  2021-11-15 11:49 ` Christian König
       [not found] ` <AFkAWADGE4YQkIdpTO49K4pP.9.1636976948000.Hmail.bernard@vivo.com.@PGViY2Y4YjMwLTczMTEtOWQ3Ny0wN2FiLTFiOTI3NTZjMGFlMEBnbWFpbC5jb20+>
  0 siblings, 2 replies; 3+ messages in thread
From: Bernard Zhao @ 2021-11-15  7:07 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Jingwen Chen, Candice Li, John Clements, Monk liu,
	Peng Ju Zhou, Bernard Zhao, Jiawei Gu, Bokun Zhang, Zhigang Luo,
	Lee Jones, amd-gfx, dri-devel, linux-kernel

This change is to cleanup the code style a bit.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 04cf9b207e62..90070b41136a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -286,12 +286,14 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
 		return -ENOMEM;
 
 	bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
+	if (!bps) {
+		kfree(*data);
+		return -ENOMEM;
+	}
 	bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
-
-	if (!bps || !bps_bo) {
-		kfree(bps);
-		kfree(bps_bo);
+	if (!bps_bo) {
 		kfree(*data);
+		kfree(bps);
 		return -ENOMEM;
 	}
 
-- 
2.33.1


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

* Re: [PATCH] drm/amd/amdgpu: cleanup the code style a bit
  2021-11-15  7:07 [PATCH] drm/amd/amdgpu: cleanup the code style a bit Bernard Zhao
@ 2021-11-15 11:49 ` Christian König
       [not found] ` <AFkAWADGE4YQkIdpTO49K4pP.9.1636976948000.Hmail.bernard@vivo.com.@PGViY2Y4YjMwLTczMTEtOWQ3Ny0wN2FiLTFiOTI3NTZjMGFlMEBnbWFpbC5jb20+>
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2021-11-15 11:49 UTC (permalink / raw)
  To: Bernard Zhao, Alex Deucher, Christian König, Pan, Xinhui,
	David Airlie, Daniel Vetter, Jingwen Chen, Candice Li,
	John Clements, Monk liu, Peng Ju Zhou, Jiawei Gu, Bokun Zhang,
	Zhigang Luo, Lee Jones, amd-gfx, dri-devel, linux-kernel

Am 15.11.21 um 08:07 schrieb Bernard Zhao:
> This change is to cleanup the code style a bit.

To be honest I think the old style looked better. It took me a moment to 
validate this now.

What you could to instead is to have goto style error handling which 
would make this a bit more cleaner I think.

Christian.

>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 04cf9b207e62..90070b41136a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -286,12 +286,14 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>   		return -ENOMEM;
>   
>   	bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
> +	if (!bps) {
> +		kfree(*data);
> +		return -ENOMEM;
> +	}
>   	bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> -
> -	if (!bps || !bps_bo) {
> -		kfree(bps);
> -		kfree(bps_bo);
> +	if (!bps_bo) {
>   		kfree(*data);
> +		kfree(bps);
>   		return -ENOMEM;
>   	}
>   


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

* 答复: [PATCH] drm/amd/amdgpu: cleanup the code style a bit
       [not found] ` <AFkAWADGE4YQkIdpTO49K4pP.9.1636976948000.Hmail.bernard@vivo.com.@PGViY2Y4YjMwLTczMTEtOWQ3Ny0wN2FiLTFiOTI3NTZjMGFlMEBnbWFpbC5jb20+>
@ 2021-11-15 12:01   ` 赵军奎
  0 siblings, 0 replies; 3+ messages in thread
From: 赵军奎 @ 2021-11-15 12:01 UTC (permalink / raw)
  To: Christian König, Alex Deucher, Christian König, Pan,
	Xinhui, David Airlie, Daniel Vetter, Jingwen Chen, Candice Li,
	John Clements, Monk liu, Peng Ju Zhou, Jiawei Gu, Bokun Zhang,
	Zhigang Luo, Lee Jones, amd-gfx, dri-devel, linux-kernel


-----邮件原件-----
发件人: bernard@vivo.com <bernard@vivo.com> 代表 Christian K?nig
发送时间: 2021年11月15日 19:49
收件人: 赵军奎 <bernard@vivo.com>; Alex Deucher <alexander.deucher@amd.com>; Christian König <christian.koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; David Airlie <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Jingwen Chen <Jingwen.Chen2@amd.com>; Candice Li <candice.li@amd.com>; John Clements <john.clements@amd.com>; Monk liu <monk.liu@amd.com>; Peng Ju Zhou <PengJu.Zhou@amd.com>; Jiawei Gu <Jiawei.Gu@amd.com>; Bokun Zhang <bokun.zhang@amd.com>; Zhigang Luo <zhigang.luo@amd.com>; Lee Jones <lee.jones@linaro.org>; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH] drm/amd/amdgpu: cleanup the code style a bit

Am 15.11.21 um 08:07 schrieb Bernard Zhao:
> This change is to cleanup the code style a bit.

>To be honest I think the old style looked better. It took me a moment to validate this now.

>What you could to instead is to have goto style error handling which would make this a bit more cleaner I think.
Hi 
Looks like a good idea, thank you for your comments!
I will resubmit a version!
BR//Bernard

>Christian.

>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 04cf9b207e62..90070b41136a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -286,12 +286,14 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
>   		return -ENOMEM;
>   
>   	bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
> +	if (!bps) {
> +		kfree(*data);
> +		return -ENOMEM;
> +	}
>   	bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), 
> GFP_KERNEL);
> -
> -	if (!bps || !bps_bo) {
> -		kfree(bps);
> -		kfree(bps_bo);
> +	if (!bps_bo) {
>   		kfree(*data);
> +		kfree(bps);
>   		return -ENOMEM;
>   	}
>   


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

end of thread, other threads:[~2021-11-15 12:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15  7:07 [PATCH] drm/amd/amdgpu: cleanup the code style a bit Bernard Zhao
2021-11-15 11:49 ` Christian König
     [not found] ` <AFkAWADGE4YQkIdpTO49K4pP.9.1636976948000.Hmail.bernard@vivo.com.@PGViY2Y4YjMwLTczMTEtOWQ3Ny0wN2FiLTFiOTI3NTZjMGFlMEBnbWFpbC5jb20+>
2021-11-15 12:01   ` 答复: " 赵军奎

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).