-----Original Message-----
From: Sousa, Gustavo <[email protected]> 
Sent: Thursday, May 28, 2026 3:30 PM
To: Cavitt, Jonathan <[email protected]>; 
[email protected]
Cc: Gupta, Saurabhg <[email protected]>; Zuo, Alex <[email protected]>; 
Cavitt, Jonathan <[email protected]>
Subject: Re: [PATCH] drm/xe/rtp: Check hwe before calling match_func
> 
> Jonathan Cavitt <[email protected]> writes:
> 
> > XE_RTP_MATCH_FUNC may attempt to dereference the target xe_hw_engine.
> > Ensure the hwe is not NULL before calling the function, matching
> > XE_RTP_MATCH_ENGINE_CLASS, for example.
> >
> > This covers a static analysis issue.
> >
> > Signed-off-by: Jonathan Cavitt <[email protected]>
> > Cc: Gustavo Sousa <[email protected]>
> > ---
> >  drivers/gpu/drm/xe/xe_rtp.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
> > index dec9d94e6fb0..2cd26db113d9 100644
> > --- a/drivers/gpu/drm/xe/xe_rtp.c
> > +++ b/drivers/gpu/drm/xe/xe_rtp.c
> > @@ -129,6 +129,9 @@ static bool rule_match_item(struct rule_match_ctx 
> > *match_ctx)
> >  
> >             return hwe->class != r->engine_class;
> >     case XE_RTP_MATCH_FUNC:
> > +           if (drm_WARN_ON(&xe->drm, !hwe))
> > +                   return false;
> 
> There are several functions passed via XE_RTP_MATCH_FUNC() (i.e. MATCH()
> in definitions of RTP rules) that are meant to be used to do checks that
> do not depend on hwe.  Returning false here is wrong as it will cause
> those checks to be skipped.
> 
> The developer is responsible for not passing a function that uses hwe in
> a context where it is NULL.

Understood, though quick question: is this also the case for GT?
-Jonathan Cavitt

> 
> --
> Gustavo Sousa
> 
> > +
> >             return r->match_func(xe, gt, hwe);
> >     default:
> >             drm_warn(&xe->drm, "Invalid RTP match %u\n",
> > -- 
> > 2.53.0
> 

Reply via email to