* [PATCH] iommufd/selftest: Fix wrong return value in iommufd_test_dmabuf_get()
@ 2026-09-03 7:24 Yi Lai
2026-09-03 7:48 ` Yee Li
0 siblings, 1 reply; 2+ messages in thread
From: Yi Lai @ 2026-09-03 7:24 UTC (permalink / raw)
To: Jason Gunthorpe, Kevin Tian, joro, Will Deacon, Robin Murphy,
yeeli, iommu, linux-kernel, yi1.lai
Commit dba4254e216d ("iommufd/selftest: Fix dmabuf leak in
iommufd_test_dmabuf_get()") broke the success path: it changed the
function to always "return 0" instead of returning the fd produced
by dma_buf_fd().
Userspace obtains the dmabuf fd from the ioctl() return value, so every
successful IOMMU_TEST_OP_DMABUF_GET now reports fd 0 instead of the real
fd, causing iommufd selftests to fail, such as:
not ok 67 iommufd_ioas.mock_domain.dmabuf_simple
not ok 94 iommufd_ioas.two_mock_domain.dmabuf_simple
Fix by returning rc unconditionally: on error it is the negative
errno from dma_buf_fd(), and on success it is the valid dmabuf fd.
Fixes: dba4254e216d ("iommufd/selftest: Fix dmabuf leak in iommufd_test_dmabuf_get()")
Signed-off-by: Yi Lai <yi1.lai@intel.com>
---
drivers/iommu/iommufd/selftest.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index ee706f18f7e9..f6da927461b5 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -2056,11 +2056,9 @@ static int iommufd_test_dmabuf_get(struct iommufd_ucmd *ucmd,
}
rc = dma_buf_fd(dmabuf, open_flags);
- if (rc < 0) {
+ if (rc < 0)
dma_buf_put(dmabuf);
- return rc;
- }
- return 0;
+ return rc;
err_free:
kfree(priv->memory);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iommufd/selftest: Fix wrong return value in iommufd_test_dmabuf_get()
2026-09-03 7:24 [PATCH] iommufd/selftest: Fix wrong return value in iommufd_test_dmabuf_get() Yi Lai
@ 2026-09-03 7:48 ` Yee Li
0 siblings, 0 replies; 2+ messages in thread
From: Yee Li @ 2026-09-03 7:48 UTC (permalink / raw)
To: Yi Lai
Cc: Jason Gunthorpe, Kevin Tian, joro, Will Deacon, Robin Murphy,
iommu, linux-kernel
Please refer,
https://lore.kernel.org/linux-iommu/20260902085414.549830-1-qinyuntan@linux.alibaba.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-03 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-03 7:24 [PATCH] iommufd/selftest: Fix wrong return value in iommufd_test_dmabuf_get() Yi Lai
2026-09-03 7:48 ` Yee Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®