Skip to content

Commit 6fc85bb

Browse files
yiliu1765jgunthorpe
authored andcommitted
iommufd: Balance veventq->num_events inc/dec
iommufd_veventq_fops_read() decrements veventq->num_events when a vevent is read out. However, the report path ony increments veventq->num_events for normal events. To be balanced, make the read path decrement num_events only for normal vevents. Fixes: e36ba5a ("iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC") Link: https://patch.msgid.link/r/20250324120034.5940-3-yi.l.liu@intel.com Signed-off-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 41464a4 commit 6fc85bb

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/iommu/iommufd/eventq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ static ssize_t iommufd_veventq_fops_read(struct file *filep, char __user *buf,
385385
break;
386386
}
387387
spin_lock(&eventq->lock);
388-
veventq->num_events--;
388+
if (!vevent_for_lost_events_header(cur))
389+
veventq->num_events--;
389390
spin_unlock(&eventq->lock);
390391
done += cur->data_len;
391392
kfree(cur);

0 commit comments

Comments
 (0)