diff mbox series

[01/13] drm/i915/gvt: fix a memory leak in intel_gvt_init_vgpu_types

Message ID 20220628051435.695540-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/13] drm/i915/gvt: fix a memory leak in intel_gvt_init_vgpu_types | expand

Commit Message

Christoph Hellwig June 28, 2022, 5:14 a.m. UTC
gvt->types needs to be freed on error.

Reported-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/gpu/drm/i915/gvt/vgpu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Zhenyu Wang June 28, 2022, 8:17 a.m. UTC | #1
On 2022.06.28 07:14:23 +0200, Christoph Hellwig wrote:
> gvt->types needs to be freed on error.
> 
> Reported-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/gpu/drm/i915/gvt/vgpu.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
> index 46da19b3225d2..5c828556cefd7 100644
> --- a/drivers/gpu/drm/i915/gvt/vgpu.c
> +++ b/drivers/gpu/drm/i915/gvt/vgpu.c
> @@ -142,7 +142,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
>  
>  		if (vgpu_types[i].weight < 1 ||
>  					vgpu_types[i].weight > VGPU_MAX_WEIGHT)
> -			return -EINVAL;
> +			goto out_free_types;
>  
>  		gvt->types[i].weight = vgpu_types[i].weight;
>  		gvt->types[i].resolution = vgpu_types[i].edid;
> @@ -167,6 +167,10 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
>  
>  	gvt->num_types = i;
>  	return 0;
> +
> +out_free_types:
> +	kfree(gvt->types);
> +	return -EINVAL;
>  }
>  
>  void intel_gvt_clean_vgpu_types(struct intel_gvt *gvt)
> -- 

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>

Thanks!
Tian, Kevin June 28, 2022, 9:41 a.m. UTC | #2
> From: Christoph Hellwig <hch@lst.de>
> Sent: Tuesday, June 28, 2022 1:14 PM
> 
> gvt->types needs to be freed on error.
> 
> Reported-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c
index 46da19b3225d2..5c828556cefd7 100644
--- a/drivers/gpu/drm/i915/gvt/vgpu.c
+++ b/drivers/gpu/drm/i915/gvt/vgpu.c
@@ -142,7 +142,7 @@  int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
 
 		if (vgpu_types[i].weight < 1 ||
 					vgpu_types[i].weight > VGPU_MAX_WEIGHT)
-			return -EINVAL;
+			goto out_free_types;
 
 		gvt->types[i].weight = vgpu_types[i].weight;
 		gvt->types[i].resolution = vgpu_types[i].edid;
@@ -167,6 +167,10 @@  int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
 
 	gvt->num_types = i;
 	return 0;
+
+out_free_types:
+	kfree(gvt->types);
+	return -EINVAL;
 }
 
 void intel_gvt_clean_vgpu_types(struct intel_gvt *gvt)