[PATCH] drm/xe: Fix coverity issue, cast_overflow
Pravalika Gurram
pravalika.gurram at intel.com
Mon Aug 4 09:40:38 UTC 2025
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;
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