Skip to contentSkip to conversation

iommufd/driver: Fix counter initialization for counted_by annotation

PATCH Applied Gustavo A. R. Silva 4 participants 4 messages Nov 11, 2025 – Nov 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommufd/driver: Fix counter initialization for counted_by annotation

One of the requirements for counted_by annotations is that the counter member must be initialized before the first reference to the flexible-array member.

Move the vevent->data_len = data_len; initialization to before the first access to flexible array vevent->event_data.

Fixes e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
---
 drivers/iommu/iommufd/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommufd/driver.c +1 -1
index 6f1010da221c..21d4a35538f6 100644
@@ -161,8 +161,8 @@ int iommufd_viommu_report_event(struct iommufd_viommu *viommu,
 		vevent = &veventq->lost_events_header;
 		goto out_set_header;
 	}
-	memcpy(vevent->event_data, event_data, data_len);
 	vevent->data_len = data_len;
+	memcpy(vevent->event_data, event_data, data_len);
 	veventq->num_events++;
 
 out_set_header:
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Gustavo A. R. Silva

One of the requirements for counted_by annotations is that the counter member must be initialized before the first reference to the flexible-array member.

Move the vevent->data_len = data_len; initialization to before the first access to flexible array vevent->event_data.

Fixes e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 7 lines

From: Gustavo A. R. Silva <[email protected]>
Sent: Tuesday, November 11, 2025 5:01 PM

One of the requirements for counted_by annotations is that the counter member must be initialized before the first reference to the flexible-array member.

Quoted 7 lines

Move the vevent->data_len = data_len; initialization to before the first access to flexible array vevent->event_data.

Fixes e8e1ef9b77a7 ("iommufd/viommu: Add

iommufd_viommu_report_event helper")

#3 lore raw
In reply to Gustavo A. R. Silva
Quoted 7 lines · Gustavo A. R. Silva

One of the requirements for counted_by annotations is that the counter member must be initialized before the first reference to the flexible-array member.

Move the vevent->data_len = data_len; initialization to before the first access to flexible array vevent->event_data.

Quoted 6 lines
Fixes e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
---
 drivers/iommu/iommufd/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Jason