From: Dan Carpenter <dan.carpenter@oracle.com>
To: paulmck@kernel.org
Cc: rcu@vger.kernel.org
Subject: [bug report] refperf: Dynamically allocate experiment-summary output buffer
Date: Fri, 29 May 2020 12:48:29 +0300 [thread overview]
Message-ID: <20200529094829.GA1302781@mwanda> (raw)
Hello Paul E. McKenney,
This is a semi-automatic email about new static checker warnings.
The patch 54c0ed208976: "refperf: Dynamically allocate
experiment-summary output buffer" from May 25, 2020, leads to the
following Smatch complaint:
kernel/rcu/refperf.c:395 main_func()
error: we previously assumed 'buf' could be null (see line 352)
kernel/rcu/refperf.c
351 buf = kzalloc(64 + nruns * 32, GFP_KERNEL);
352 if (!result_avg || !buf) {
^^^^
Check for NULL
353 VERBOSE_PERFOUT_ERRSTRING("out of memory");
354 errexit = true;
355 }
356 atomic_inc(&n_init);
357
358 // Wait for all threads to start.
359 wait_event(main_wq, atomic_read(&n_init) == (nreaders + 1));
360
361 // Start exp readers up per experiment
362 for (exp = 0; exp < nruns && !torture_must_stop(); exp++) {
363 if (errexit)
364 break;
365 if (torture_must_stop())
366 goto end;
367
368 reset_readers();
369 atomic_set(&nreaders_exp, nreaders);
370
371 exp_idx = exp;
372
373 for (r = 0; r < nreaders; r++) {
374 atomic_set(&reader_tasks[r].start, 1);
375 wake_up(&reader_tasks[r].wq);
376 }
377
378 VERBOSE_PERFOUT("main_func: experiment started, waiting for %d readers",
379 nreaders);
380
381 wait_event(main_wq,
382 !atomic_read(&nreaders_exp) || torture_must_stop());
383
384 VERBOSE_PERFOUT("main_func: experiment ended");
385
386 if (torture_must_stop())
387 goto end;
388
389 result_avg[exp] = 1000 * process_durations(nreaders) / (nreaders * loops);
390 }
391
392 // Print the average of all experiments
393 PERFOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
394
395 buf[0] = 0;
^^^^^^
Unchecked dereferences.
396 strcat(buf, "\n");
397 strcat(buf, "Threads\tTime(ns)\n");
regards,
dan carpenter
next reply other threads:[~2020-05-29 9:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 9:48 Dan Carpenter [this message]
2020-05-29 17:55 ` [bug report] refperf: Dynamically allocate experiment-summary output buffer Joel Fernandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200529094829.GA1302781@mwanda \
--to=dan.carpenter@oracle.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox