On 11/11/25 16:20, Gustavo A. R. Silva wrote:


On 11/11/25 03:02, Nicolin Chen wrote:
On Mon, Nov 10, 2025 at 08:35:31PM +0900, Gustavo A. R. Silva wrote:
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Move the conflicting declaration to the end of the corresponding
structure. Notice that struct iommufd_vevent is a flexible
structure, this is a structure that contains a flexible-array
member.

Fix the following warning:

drivers/iommu/iommufd/iommufd_private.h:621:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array- member-not-at-end]

IIUIC, there might be data corruption due to this? If so, I think

Okay, I didn't find evidence of data corruption. So, this patch can be applied 
to
a -next tree.


Yep. Also, after taking a look at the commit you mention, the counted_by 
annotation
in struct iommufd_vevent is wrong in commit e8e1ef9b77a7 ("iommufd/viommu: Add
iommufd_viommu_report_event helper"). The counter, in this case vevent->data_len
must always be initialized before the first reference to the flexible array:

diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
index 6f1010da221c..21d4a35538f6 100644
--- a/drivers/iommu/iommufd/driver.c
+++ b/drivers/iommu/iommufd/driver.c
@@ -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:

I will submit the above as a separate patch.

Thanks
-Gustavo


Reply via email to