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

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed Apr 3 17:25:05 UTC 2024


Hi Lucas,
On 2024-04-02 at 15:17:10 -0700, Lucas De Marchi wrote:
> 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;
>  	}

While you are at this add newline here.

With or without it:
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> -	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