public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
@ 2025-10-14 21:48 Nicolin Chen
  2025-10-16  7:47 ` Tian, Kevin
  2025-10-20 23:01 ` Jason Gunthorpe
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolin Chen @ 2025-10-14 21:48 UTC (permalink / raw)
  To: jgg, kevin.tian
  Cc: shuah, alessandro.zanni87, iommu, linux-kselftest, linux-kernel

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")
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 tools/testing/selftests/iommu/iommufd_utils.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/iommu/iommufd_utils.h b/tools/testing/selftests/iommu/iommufd_utils.h
index 772ca1db6e597..9f472c20c1905 100644
--- a/tools/testing/selftests/iommu/iommufd_utils.h
+++ b/tools/testing/selftests/iommu/iommufd_utils.h
@@ -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;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
  2025-10-14 21:48 [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents() Nicolin Chen
@ 2025-10-16  7:47 ` Tian, Kevin
  2025-10-16  9:09   ` Alessandro Zanni
  2025-10-20 23:01 ` Jason Gunthorpe
  1 sibling, 1 reply; 5+ messages in thread
From: Tian, Kevin @ 2025-10-16  7:47 UTC (permalink / raw)
  To: Nicolin Chen, jgg@nvidia.com
  Cc: shuah@kernel.org, alessandro.zanni87@gmail.com,
	iommu@lists.linux.dev, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org

> From: Nicolin Chen <nicolinc@nvidia.com>
> 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")
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
  2025-10-16  7:47 ` Tian, Kevin
@ 2025-10-16  9:09   ` Alessandro Zanni
  2025-10-16 15:22     ` Nicolin Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Alessandro Zanni @ 2025-10-16  9:09 UTC (permalink / raw)
  To: Tian, Kevin
  Cc: Nicolin Chen, jgg@nvidia.com, shuah@kernel.org,
	alessandro.zanni87@gmail.com, iommu@lists.linux.dev,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org

On Thu, Oct 16, 2025 at 07:47:20AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@nvidia.com>
> > 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")
> > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> 
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>

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?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
  2025-10-16  9:09   ` Alessandro Zanni
@ 2025-10-16 15:22     ` Nicolin Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2025-10-16 15:22 UTC (permalink / raw)
  To: Alessandro Zanni
  Cc: Tian, Kevin, jgg@nvidia.com, shuah@kernel.org,
	alessandro.zanni87@gmail.com, iommu@lists.linux.dev,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org

On Thu, Oct 16, 2025 at 11:09:59AM +0200, Alessandro Zanni wrote:
> On Thu, Oct 16, 2025 at 07:47:20AM +0000, Tian, Kevin wrote:
> > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > 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")
> > > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> > 
> > Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
  2025-10-14 21:48 [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents() Nicolin Chen
  2025-10-16  7:47 ` Tian, Kevin
@ 2025-10-20 23:01 ` Jason Gunthorpe
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2025-10-20 23:01 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: kevin.tian, shuah, alessandro.zanni87, iommu, linux-kselftest,
	linux-kernel

On Tue, Oct 14, 2025 at 02:48:46PM -0700, Nicolin Chen wrote:
> 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")
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>  tools/testing/selftests/iommu/iommufd_utils.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-rc, thanks

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-20 23:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 21:48 [PATCH rc] iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents() Nicolin Chen
2025-10-16  7:47 ` Tian, Kevin
2025-10-16  9:09   ` Alessandro Zanni
2025-10-16 15:22     ` Nicolin Chen
2025-10-20 23:01 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox