Re: [PATCH] drm/i915/gvt: Fix error code in intel_gvt_init_device()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2021.04.14 09:01:38 +0300, Dan Carpenter wrote:
> The intel_gvt_init_vgpu_type_groups() function is only called from
> intel_gvt_init_device().  If it fails then the intel_gvt_init_device()
> prints the error code and propagates it back again.  That's a bug
> because false is zero/success.  The fix is to modify it to return zero
> or negative error codes and make everything consistent.
> 
> Fixes: c5d71cb31723 ("drm/i915/gvt: Move vGPU type related code into gvt file")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---

Reviewed-by: Zhenyu Wang <zhenyuw@xxxxxxxxxxxxxxx>

Thanks, Dan! Applied this.

>  drivers/gpu/drm/i915/gvt/gvt.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
> index 2ecb8534930b..1deb253ffe80 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.c
> +++ b/drivers/gpu/drm/i915/gvt/gvt.c
> @@ -126,7 +126,7 @@ static bool intel_get_gvt_attrs(struct attribute_group ***intel_vgpu_type_groups
>  	return true;
>  }
>  
> -static bool intel_gvt_init_vgpu_type_groups(struct intel_gvt *gvt)
> +static int intel_gvt_init_vgpu_type_groups(struct intel_gvt *gvt)
>  {
>  	int i, j;
>  	struct intel_vgpu_type *type;
> @@ -144,7 +144,7 @@ static bool intel_gvt_init_vgpu_type_groups(struct intel_gvt *gvt)
>  		gvt_vgpu_type_groups[i] = group;
>  	}
>  
> -	return true;
> +	return 0;
>  
>  unwind:
>  	for (j = 0; j < i; j++) {
> @@ -152,7 +152,7 @@ static bool intel_gvt_init_vgpu_type_groups(struct intel_gvt *gvt)
>  		kfree(group);
>  	}
>  
> -	return false;
> +	return -ENOMEM;
>  }
>  
>  static void intel_gvt_cleanup_vgpu_type_groups(struct intel_gvt *gvt)
> @@ -373,7 +373,7 @@ int intel_gvt_init_device(struct drm_i915_private *i915)
>  		goto out_clean_thread;
>  
>  	ret = intel_gvt_init_vgpu_type_groups(gvt);
> -	if (ret == false) {
> +	if (ret) {
>  		gvt_err("failed to init vgpu type groups: %d\n", ret);
>  		goto out_clean_types;
>  	}
> -- 
> 2.30.2
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux