Skip to content

Commit

Permalink
core: pager: fix arguments passed to calloc in alloc_merged_pgt_array()
Browse files Browse the repository at this point in the history
An error was reported when compiling with GCC14 on this calloc:

core/arch/arm/mm/tee_pager.c: In function 'alloc_merged_pgt_array':
core/arch/arm/mm/tee_pager.c:934:35: warning: 'calloc' sizes specified
with 'sizeof' in the earlier argument and not in the later argument
[-Wcalloc-transposed-args]
   934 |         pgt_array = calloc(sizeof(struct pgt *), pgt_count);
       |                                   ^~~~~~

Looking at the code, it seems that pgt_count and sizeof(struct pgt *)
are inverted.

Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Fixes: 60e3671 ("core: pager fix alloc_merged_pgt_array()")
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
GseoC authored and jforissier committed May 24, 2024
1 parent 6b5d112 commit ae9b419
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/arch/arm/mm/tee_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ static struct pgt **alloc_merged_pgt_array(struct vm_paged_region *a,
a->pgt_array[a_pgt_count - 1] != a_next->pgt_array[0])
return NULL;

pgt_array = calloc(sizeof(struct pgt *), pgt_count);
pgt_array = calloc(pgt_count, sizeof(struct pgt *));
if (!pgt_array)
return NULL;

Expand Down

0 comments on commit ae9b419

Please sign in to comment.