[PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc()

Rodrigo Vivi rodrigo.vivi at intel.com
Mon Jun 16 15:01:08 UTC 2025


On Fri, Jun 06, 2025 at 12:04:49PM +0300, Dan Carpenter wrote:
> The __mock_request_alloc() implements the smoketest->request_alloc()
> function pointer.  It's called from __igt_breadcrumbs_smoketest().
> It's supposed to return error pointers, and returning NULL will lead to
> a NULL pointer dereference.
> 
> Fixes: 52c0fdb25c7c ("drm/i915: Replace global breadcrumbs with per-context interrupt tracking")
> Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
> ---
>  drivers/gpu/drm/i915/selftests/i915_request.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
> index 88870844b5bd..e349244a5fba 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_request.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_request.c
> @@ -290,7 +290,12 @@ struct smoketest {
>  static struct i915_request *
>  __mock_request_alloc(struct intel_context *ce)
>  {
> -	return mock_request(ce, 0);
> +	struct i915_request *rq;
> +
> +	rq = mock_request(ce, 0);
> +	if (!rq)
> +		return ERR_PTR(-ENOMEM);

I believe we should fix mock_request and make it to stop replacing the
error per NULL, and make the callers to check for IS_ERR instead of is not NULL.

Then don't need to make up an error here.

> +	return rq;
>  }
>  
>  static struct i915_request *
> -- 
> 2.47.2
> 


More information about the Intel-gfx mailing list