[PATCH 4/7] accel/qaic: Drop the reference to BO in error path of create BO IOCTL

Jacek Lawrynowicz jacek.lawrynowicz at linux.intel.com
Mon Dec 11 11:25:12 UTC 2023


Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz at linux.intel.com>

On 08.12.2023 17:34, Jeffrey Hugo wrote:
> From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy at quicinc.com>
> 
> Do not free BO explicitly in error path, just drop its reference, cleanup
> will be taken care by DRM as we have registered for ->free() callback.
> This patch makes sure that there is only one code path for BO to be freed.
> 
> Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy at quicinc.com>
> Reviewed-by: Carl Vanderlip <quic_carlv at quicinc.com>
> Reviewed-by: Jeffrey Hugo <quic_jhugo at quicinc.com>
> Signed-off-by: Jeffrey Hugo <quic_jhugo at quicinc.com>
> ---
>  drivers/accel/qaic/qaic_data.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> index 89ab8fa19315..7faa00705c1d 100644
> --- a/drivers/accel/qaic/qaic_data.c
> +++ b/drivers/accel/qaic/qaic_data.c
> @@ -574,6 +574,9 @@ static void qaic_free_sgt(struct sg_table *sgt)
>  {
>  	struct scatterlist *sg;
>  
> +	if (!sgt)
> +		return;
> +
>  	for (sg = sgt->sgl; sg; sg = sg_next(sg))
>  		if (sg_page(sg))
>  			__free_pages(sg_page(sg), get_order(sg->length));
> @@ -717,7 +720,7 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
>  
>  	ret = drm_gem_handle_create(file_priv, obj, &args->handle);
>  	if (ret)
> -		goto free_sgt;
> +		goto free_bo;
>  
>  	bo->handle = args->handle;
>  	drm_gem_object_put(obj);
> @@ -726,10 +729,8 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
>  
>  	return 0;
>  
> -free_sgt:
> -	qaic_free_sgt(bo->sgt);
>  free_bo:
> -	kfree(bo);
> +	drm_gem_object_put(obj);
>  unlock_dev_srcu:
>  	srcu_read_unlock(&qdev->dev_lock, qdev_rcu_id);
>  unlock_usr_srcu:


More information about the dri-devel mailing list