From: Paul E. McKenney Date: Tue, 26 May 2020 00:45:03 +0000 (-0700) Subject: refperf: Dynamically allocate thread-summary output buffer X-Git-Tag: v5.9-rc1~204^2^2^5~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e90de76f226f11fe26c871aa321be28152f565a;p=thirdparty%2Flinux.git refperf: Dynamically allocate thread-summary output buffer Currently, the buffer used to accumulate the thread-summary output is fixed size, which will cause problems if someone decides to run on a large number of PCUs. This commit therefore dynamically allocates this buffer. [ paulmck: Fix memory allocation as suggested by KASAN. ] Cc: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney --- diff --git a/kernel/rcu/refperf.c b/kernel/rcu/refperf.c index 75b9cceaece13..fc940e3dba1f9 100644 --- a/kernel/rcu/refperf.c +++ b/kernel/rcu/refperf.c @@ -301,9 +301,12 @@ u64 process_durations(int n) int i; struct reader_task *rt; char buf1[64]; - char buf[512]; + char *buf; u64 sum = 0; + buf = kmalloc(128 + nreaders * 32, GFP_KERNEL); + if (!buf) + return 0; buf[0] = 0; sprintf(buf, "Experiment #%d (Format: :)", exp_idx); @@ -322,6 +325,7 @@ u64 process_durations(int n) PERFOUT("%s\n", buf); + kfree(buf); return sum; }