perf bench numa: Fix type of loop iterator in do_work, it should be 'long'
authorAndreas Herrmann <aherrmann@suse.de>
Thu, 30 Mar 2023 07:42:02 +0000 (09:42 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Apr 2023 12:39:56 +0000 (09:39 -0300)
'j' is of type int and start/end are of type 'long'. Thus 'j' might become
negative and cause segfault in access_data(). Fix it by using 'long' for
'j' as well.

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
Link: https://lore.kernel.org/r/20230330074202.14052-1-aherrmann@suse.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/bench/numa.c

index 9717c6c17433c22d7a605808a7800f4837cd35c1..1fbd7c947abc2b2ae713644a8fbb0d1c7480933d 100644 (file)
@@ -847,7 +847,7 @@ static u64 do_work(u8 *__data, long bytes, int nr, int nr_max, int loop, u64 val
 
        if (g->p.data_rand_walk) {
                u32 lfsr = nr + loop + val;
-               int j;
+               long j;
 
                for (i = 0; i < words/1024; i++) {
                        long start, end;