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/[email protected] Signed-off-by: Yi Liu <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Tested-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 41464a4 commit 6fc85bb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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)