All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] refperf: Dynamically allocate experiment-summary output buffer
@ 2020-05-29  9:48 Dan Carpenter
  2020-05-29 17:55 ` Joel Fernandes
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-05-29  9:48 UTC (permalink / raw)
  To: paulmck; +Cc: rcu

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] refperf: Dynamically allocate experiment-summary output buffer
  2020-05-29  9:48 [bug report] refperf: Dynamically allocate experiment-summary output buffer Dan Carpenter
@ 2020-05-29 17:55 ` Joel Fernandes
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Fernandes @ 2020-05-29 17:55 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: paulmck, rcu

On Fri, May 29, 2020 at 12:48:29PM +0300, Dan Carpenter wrote:
> 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

Makes sense. Looks like Paul already fixed it so should be good.

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-29 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29  9:48 [bug report] refperf: Dynamically allocate experiment-summary output buffer Dan Carpenter
2020-05-29 17:55 ` Joel Fernandes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.