All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: dave.jiang@intel.com
Cc: linux-ntb@googlegroups.com
Subject: re: ntb: ntb perf tool
Date: Thu, 17 Mar 2016 20:50:44 +0300	[thread overview]
Message-ID: <20160317175044.GA24724@mwanda> (raw)

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

                 reply	other threads:[~2016-03-17 17:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160317175044.GA24724@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-ntb@googlegroups.com \
    /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 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.