summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolin Chen <nicolinc@nvidia.com>2026-06-01 13:42:32 -0700
committerJason Gunthorpe <jgg@nvidia.com>2026-06-05 11:07:11 -0300
commit01e41ad76c12ae5c49ab4ef4fc7dd54e9b8784d6 (patch)
tree4878d5928de914a2814f9dc5e3394465097b8157
parentf25989c19028e8bf81e26e1133a99e3436c3afc2 (diff)
downloadlinux-01e41ad76c12ae5c49ab4ef4fc7dd54e9b8784d6.tar.gz
linux-01e41ad76c12ae5c49ab4ef4fc7dd54e9b8784d6.zip
iommufd: Rewind header length in done if iommufd_veventq_fops_read() fails
When the first event copy fails, rc = -EFAULT will not be reported as done is set to the length of the copied header. Rewind it to report rc correctly. Fixes: e36ba5ab808e ("iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC") Link: https://patch.msgid.link/r/78f8caeb6a5d667a26b870e3068cec47dd4b5be1.1780343944.git.nicolinc@nvidia.com Cc: stable@vger.kernel.org Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Pranjal Shrivastava <praan@google.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
-rw-r--r--drivers/iommu/iommufd/eventq.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/iommu/iommufd/eventq.c b/drivers/iommu/iommufd/eventq.c
index 1f1e415285b1..896f45be0d2e 100644
--- a/drivers/iommu/iommufd/eventq.c
+++ b/drivers/iommu/iommufd/eventq.c
@@ -336,6 +336,7 @@ static ssize_t iommufd_veventq_fops_read(struct file *filep, char __user *buf,
if (cur->data_len &&
copy_to_user(buf + done, cur->event_data, cur->data_len)) {
iommufd_veventq_deliver_restore(veventq, cur);
+ done -= sizeof(*hdr);
rc = -EFAULT;
break;
}