[Intel-gfx] [PATCH] drm/i915/guc: Fix potential null pointer deref in GuC 'steal id' test

Andi Shyti andi.shyti at linux.intel.com
Thu Aug 3 13:28:29 UTC 2023


Hi John,

On Wed, Aug 02, 2023 at 11:49:40AM -0700, John.C.Harrison at Intel.com wrote:
> From: John Harrison <John.C.Harrison at Intel.com>
> 
> It was noticed that if the very first 'stealing' request failed to
> create for some reason then the 'steal all ids' loop would immediately
> exit with 'last' still being NULL. The test would attempt to continue
> but using a null pointer. Fix that by aborting the test if it fails to
> create any requests at all.
> 
> Signed-off-by: John Harrison <John.C.Harrison at Intel.com>
> ---
>  drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
> index 1fd760539f77b..bfb72143566f6 100644
> --- a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
> +++ b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
> @@ -204,9 +204,9 @@ static int intel_guc_steal_guc_ids(void *arg)
>  		if (IS_ERR(rq)) {
>  			ret = PTR_ERR(rq);
>  			rq = NULL;
> -			if (ret != -EAGAIN) {
> -				guc_err(guc, "Failed to create request %d: %pe\n",
> -					context_index, ERR_PTR(ret));
> +			if ((ret != -EAGAIN) || !last) {

isn't last alway NULL here?

Andi

> +				guc_err(guc, "Failed to create %srequest %d: %pe\n",
> +					last ? "" : "first ", context_index, ERR_PTR(ret));
>  				goto err_spin_rq;
>  			}
>  		} else {
> -- 
> 2.39.1


More information about the Intel-gfx mailing list