diff mbox series

[next] drm/v3d: Fix missing error code in v3d_submit_cpu_ioctl()

Message ID 20231204122102.181298-1-harshit.m.mogalapalli@oracle.com (mailing list archive)
State New, archived
Headers show
Series [next] drm/v3d: Fix missing error code in v3d_submit_cpu_ioctl() | expand

Commit Message

Harshit Mogalapalli Dec. 4, 2023, 12:21 p.m. UTC
Smatch warns:
	drivers/gpu/drm/v3d/v3d_submit.c:1222 v3d_submit_cpu_ioctl()
	warn: missing error code 'ret'

When there is no job type or job is submitted with wrong number of BOs
it is an error path, ret is zero at this point which is incorrect
return.

Fix this by changing it to -EINVAL.

Fixes: aafc1a2bea67 ("drm/v3d: Add a CPU job submission")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is based on static analysis and only compile tested.
---
 drivers/gpu/drm/v3d/v3d_submit.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Melissa Wen Dec. 4, 2023, 2:50 p.m. UTC | #1
On 12/04, Harshit Mogalapalli wrote:
> Smatch warns:
> 	drivers/gpu/drm/v3d/v3d_submit.c:1222 v3d_submit_cpu_ioctl()
> 	warn: missing error code 'ret'
> 
> When there is no job type or job is submitted with wrong number of BOs
> it is an error path, ret is zero at this point which is incorrect
> return.
> 
> Fix this by changing it to -EINVAL.
> 
> Fixes: aafc1a2bea67 ("drm/v3d: Add a CPU job submission")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> This is based on static analysis and only compile tested.
> ---
>  drivers/gpu/drm/v3d/v3d_submit.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
> index d7a9da2484fd..fcff41dd2315 100644
> --- a/drivers/gpu/drm/v3d/v3d_submit.c
> +++ b/drivers/gpu/drm/v3d/v3d_submit.c
> @@ -1219,11 +1219,13 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,
>  	/* Every CPU job must have a CPU job user extension */
>  	if (!cpu_job->job_type) {
>  		DRM_DEBUG("CPU job must have a CPU job user extension.\n");
> +		ret = -EINVAL;
>  		goto fail;
>  	}
>  
>  	if (args->bo_handle_count != cpu_job_bo_handle_count[cpu_job->job_type]) {
>  		DRM_DEBUG("This CPU job was not submitted with the proper number of BOs.\n");
> +		ret = -EINVAL;

Nice catch. Thanks!

Reviewed-by: Melissa Wen <mwen@igalia.com>

I'll apply to drm-misc-next.

>  		goto fail;
>  	}
>  
> -- 
> 2.39.3
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
index d7a9da2484fd..fcff41dd2315 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -1219,11 +1219,13 @@  v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,
 	/* Every CPU job must have a CPU job user extension */
 	if (!cpu_job->job_type) {
 		DRM_DEBUG("CPU job must have a CPU job user extension.\n");
+		ret = -EINVAL;
 		goto fail;
 	}
 
 	if (args->bo_handle_count != cpu_job_bo_handle_count[cpu_job->job_type]) {
 		DRM_DEBUG("This CPU job was not submitted with the proper number of BOs.\n");
+		ret = -EINVAL;
 		goto fail;
 	}