[PATCH i-g-t] tests/intel/xe_oa: Avoid divide by zero SIGFPE

Ashutosh Dixit ashutosh.dixit at intel.com
Thu May 15 20:18:04 UTC 2025


It is planned for future OA units to have 0 engines attached to them. Avoid
divide by zero SIGFPE for these cases.

Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
 tests/intel/xe_oa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
index 1576479d98..73841a359d 100644
--- a/tests/intel/xe_oa.c
+++ b/tests/intel/xe_oa.c
@@ -445,7 +445,7 @@ static struct drm_xe_engine_class_instance *oa_unit_engine(int fd, int n)
 		oau = (struct drm_xe_oa_unit *)poau;
 
 		if (i == n) {
-			hwe = &oau->eci[random() % oau->num_engines];
+			hwe = oau->num_engines ? &oau->eci[random() % oau->num_engines] : NULL;
 			break;
 		}
 		poau += sizeof(*oau) + oau->num_engines * sizeof(oau->eci[0]);
-- 
2.48.1



More information about the igt-dev mailing list