[PATCH i-g-t 2/8] lib/igt_drm_clients: Fix sizeof calculation

Lucas De Marchi lucas.demarchi at intel.com
Tue Apr 2 22:17:10 UTC 2024


val and last are arrays of certain types. For the latter, it's
underallocated on 32-bits since it should be sizeof(u64) not the size of
a pointer. When running on 64-bits, no real bug.

Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
 lib/igt_drm_clients.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
index 90ca6d61c..c8dc21d6a 100644
--- a/lib/igt_drm_clients.c
+++ b/lib/igt_drm_clients.c
@@ -182,8 +182,8 @@ igt_drm_client_add(struct igt_drm_clients *clients,
 		c->engines->num_engines++;
 		c->engines->max_engine_id = i;
 	}
-	c->val = calloc(c->engines->max_engine_id + 1, sizeof(c->val));
-	c->last = calloc(c->engines->max_engine_id + 1, sizeof(c->last));
+	c->val = calloc(c->engines->max_engine_id + 1, sizeof(*c->val));
+	c->last = calloc(c->engines->max_engine_id + 1, sizeof(*c->last));
 	assert(c->val && c->last);
 
 	/* Memory regions */
-- 
2.43.0



More information about the igt-dev mailing list