From: Yi Lai <yi1.lai@intel.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
joro@8bytes.org, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
yeeli <seven.yi.lee@gmail.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
yi1.lai@intel.com
Subject: [PATCH] iommufd/selftest: Fix wrong return value in iommufd_test_dmabuf_get()
Date: Thu, 3 Sep 2026 15:24:19 +0800 [thread overview]
Message-ID: <20260903072419.1485256-1-yi1.lai@intel.com> (raw)
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
next reply other threads:[~2026-09-03 7:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 7:24 Yi Lai [this message]
2026-09-03 7:48 ` Yee Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260903072419.1485256-1-yi1.lai@intel.com \
--to=yi1.lai@intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=seven.yi.lee@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®