Linux PCI Non-Transparent Bridge framework and drivers
 help / color / mirror / Atom feed
* re: ntb: ntb perf tool
@ 2016-03-17 17:50 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2016-03-17 17:50 UTC (permalink / raw)
  To: dave.jiang; +Cc: linux-ntb

Hello Dave Jiang,

The patch 8a7b6a778a85: "ntb: ntb perf tool" from Jan 13, 2016, leads
to the following static checker warning:

	drivers/ntb/test/ntb_perf.c:608 debugfs_run_write()
	error: 'pctx->thread' dereferencing possible ERR_PTR()

drivers/ntb/test/ntb_perf.c
   597                  for (i = 0; i < perf->perf_threads; i++) {
   598                          struct pthr_ctx *pctx;
   599  
   600                          pctx = &perf->pthr_ctx[i];
   601                          atomic_set(&pctx->dma_sync, 0);
   602                          pctx->perf = perf;
   603                          pctx->thread =
   604                                  kthread_create_on_node(ntb_perf_thread,
   605                                                         (void *)pctx,
   606                                                         node, "ntb_perf %d", i);

kthread_create_on_node() returns error pointers, never NULL.

   607                          if (pctx->thread)

It's better to flip this test around so it does failure handling instead
of success handling.

   608                                  wake_up_process(pctx->thread);
   609                          else {
   610                                  perf->run = false;
   611                                  for (i = 0; i < MAX_THREADS; i++) {

This loop doesn't make sense because we already tested "pctx->thread"
and because we're setting the same pointer to NULL 32 times in a row.

   612                                          if (pctx->thread) {
   613                                                  kthread_stop(pctx->thread);
   614                                                  pctx->thread = NULL;
   615                                          }
   616                                  }
   617                          }
   618  
   619                          if (perf->run == false)
   620                                  return -ENXIO;
   621                  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-17 17:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-17 17:50 ntb: ntb perf tool Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox