[PATCH] drm/xe: Fix coverity issue, cast_overflow

Gurram, Pravalika pravalika.gurram at intel.com
Tue Aug 5 06:58:11 UTC 2025



> -----Original Message-----
> From: Brost, Matthew <matthew.brost at intel.com>
> Sent: Tuesday, August 5, 2025 9:08 AM
> To: Gurram, Pravalika <pravalika.gurram at intel.com>
> Cc: intel-xe at lists.freedesktop.org; Wajdeczko, Michal
> <Michal.Wajdeczko at intel.com>
> Subject: Re: [PATCH] drm/xe: Fix coverity issue, cast_overflow
> 
> On Mon, Aug 04, 2025 at 03:10:38PM +0530, Pravalika Gurram wrote:
> > Add bounds check for error code assignment.
> > Prevent integer truncation when assigning 64-bit return values to
> > 32-bit error codes by validating the range before casting.
> > Fall back to -ETIMEDOUT for out-of-range values.
> >
> > Fixes: 16ba2b28df3a8 ("drm/xe/pf: Add function to sanitize VF
> > resources")
> >
> > Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > index f00cce81f1ff..2fa1a4fba1ca 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > @@ -2091,7 +2091,7 @@ static int pf_sanitize_lmem(struct xe_tile *tile,
> struct xe_bo *bo, long timeout
> >  	} else {
> >  		long ret = dma_fence_wait_timeout(fence, false, timeout);
> >
> > -		err = ret > 0 ? 0 : ret < 0 ? ret : -ETIMEDOUT;
> > +		err = ret > 0 ? 0 : (ret < 0 && ret >= INT_MIN) ? (int)ret :
> > +-ETIMEDOUT;
> 
> This looks like false positive similar to [1]. 'ret' here will be positive (success), 0
> (timeout), or ERESTARTSYS.
> 
> IMO we don't need aggesive defensive programing here as the returns from
> dma_fence_wait_timeout are well defined.
> 
> Matt
> 
> [1] https://patchwork.freedesktop.org/series/152488/
> 
sure thanks for input will mark it as false positive 
> >  		dma_fence_put(fence);
> >  		if (!err)
> >  			xe_gt_sriov_dbg_verbose(tile->primary_gt, "LMEM
> cleared in
> > %dms\n",
> > --
> > 2.34.1
> >


More information about the Intel-xe mailing list