Module: Mesa
Branch: main
Commit: f9bab3566bcfbf4d33bcbb9fb8d5e8d416cb5674
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9bab3566bcfbf4d33bcbb9fb8d5e8d416cb5674

Author: Lionel Landwerlin <[email protected]>
Date:   Mon Nov 20 11:43:24 2023 +0200

intel/perf: fix querying of configurations

Using the unsized data field is incorrect. The data is located behind
the entire drm_i915_query_perf_config structure.

Signed-off-by: Lionel Landwerlin <[email protected]>
Cc: mesa-stable
Reviewed-by: Rohan Garg <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26285>

---

 src/intel/perf/intel_perf.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c
index 8e11a64d338..975fcfc5772 100644
--- a/src/intel/perf/intel_perf.c
+++ b/src/intel/perf/intel_perf.c
@@ -280,18 +280,19 @@ i915_query_perf_config_data(struct intel_perf_config 
*perf,
 {
    char data[sizeof(struct drm_i915_query_perf_config) +
              sizeof(struct drm_i915_perf_oa_config)] = {};
-   struct drm_i915_query_perf_config *query = (void *)data;
+   struct drm_i915_query_perf_config *i915_query = (void *)data;
+   struct drm_i915_perf_oa_config *i915_config = (void *)data + 
sizeof(*i915_query);
 
-   memcpy(query->uuid, guid, sizeof(query->uuid));
-   memcpy(query->data, config, sizeof(*config));
+   memcpy(i915_query->uuid, guid, sizeof(i915_query->uuid));
+   memcpy(i915_config, config, sizeof(*config));
 
    int32_t item_length = sizeof(data);
    if (intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
                               DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
-                              query, &item_length))
+                              i915_query, &item_length))
       return false;
 
-   memcpy(config, query->data, sizeof(*config));
+   memcpy(config, i915_config, sizeof(*config));
 
    return true;
 }

Reply via email to