Skip to content

Commit cac7ea5

Browse files
ColinIanKingakpm00
authored andcommitted
radix tree test suite: fix incorrect allocation size for pthreads
Currently the pthread allocation for each array item is based on the size of a pthread_t pointer and should be the size of the pthread_t structure, so the allocation is under-allocating the correct size. Fix this by using the size of each element in the pthreads array. Static analysis cppcheck reported: tools/testing/radix-tree/regression1.c:180:2: warning: Size of pointer 'threads' used instead of size of its data. [pointerSize] Link: https://lkml.kernel.org/r/20230727160930.632674-1-colin.i.king@gmail.com Fixes: 1366c37 ("radix tree test harness") Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f443fd5 commit cac7ea5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/testing/radix-tree/regression1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void regression1_test(void)
177177
nr_threads = 2;
178178
pthread_barrier_init(&worker_barrier, NULL, nr_threads);
179179

180-
threads = malloc(nr_threads * sizeof(pthread_t *));
180+
threads = malloc(nr_threads * sizeof(*threads));
181181

182182
for (i = 0; i < nr_threads; i++) {
183183
arg = i;

0 commit comments

Comments
 (0)