From: Yi Liu Date: Mon, 24 Mar 2025 12:00:34 +0000 (-0700) Subject: iommufd: Balance veventq->num_events inc/dec X-Git-Tag: v6.15-rc1~69^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fc85bbbeaeae39c61d230ce279c0b0d0952d3e3;p=thirdparty%2Fkernel%2Flinux.git 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: e36ba5ab808e ("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 Reviewed-by: Nicolin Chen Tested-by: Nicolin Chen Signed-off-by: Jason Gunthorpe --- diff --git a/drivers/iommu/iommufd/eventq.c b/drivers/iommu/iommufd/eventq.c index 4c43ace8c725d..f39cf07973476 100644 --- a/drivers/iommu/iommufd/eventq.c +++ b/drivers/iommu/iommufd/eventq.c @@ -385,7 +385,8 @@ static ssize_t iommufd_veventq_fops_read(struct file *filep, char __user *buf, break; } spin_lock(&eventq->lock); - veventq->num_events--; + if (!vevent_for_lost_events_header(cur)) + veventq->num_events--; spin_unlock(&eventq->lock); done += cur->data_len; kfree(cur);