Skip to contentSkip to conversation

iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()

PATCH Applied Nicolin Chen 4 participants 5 messages Oct 14, 2025 – Oct 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()

The ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.

Drop the '!' to fix it.

Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")
---
 tools/testing/selftests/iommu/iommufd_utils.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/iommu/iommufd_utils.h +2 -2
index 772ca1db6e597..9f472c20c1905 100644
@@ -1044,8 +1044,8 @@ static int _test_cmd_trigger_vevents(int fd, __u32 dev_id, __u32 nvevents)
 	};
 
 	while (nvevents--) {
-		if (!ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
-			    &trigger_vevent_cmd))
+		if (ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
+			  &trigger_vevent_cmd))
 			return -1;
 	}
 	return 0;
Signature · 1 line
2.43.0
#2 lore raw
Quoted 11 lines · Kevin
Quoted 9 lines

From: Nicolin Chen <[email protected]>
Sent: Wednesday, October 15, 2025 5:49 AM

The ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.

Drop the '!' to fix it.

Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")

With this fix a positive value returned by the ioctl() ends the loop and returns -1 to the assert.
Maybe better to put ioctl()<0 in the if condition?

#3 lore raw
Quoted 8 lines · Alessandro Zanni
Quoted 7 lines · Kevin
Quoted 7 lines

From: Nicolin Chen <[email protected]>
Sent: Wednesday, October 15, 2025 5:49 AM

The ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.

Drop the '!' to fix it.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")

With this fix a positive value returned by the ioctl() ends the loop and returns -1 to the assert.

Not with this particular ioctl(). And in fact, I don't recall we have an ioctl in iommufd uAPI that returns a positive value. All the other ioctls in selftest check "if (ret)".

Nicolin

maintainer Applied
#4 lore raw
In reply to Nicolin Chen
Quoted 9 lines · Nicolin Chen

The ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.

Drop the '!' to fix it.

Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")
---
 tools/testing/selftests/iommu/iommufd_utils.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-rc, thanks

Jason