linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: tadeusz.struk@intel.com
Cc: Jason Gunthorpe <jgg@ziepe.ca>, linux-integrity@vger.kernel.org
Subject: [bug report] tpm: add support for nonblocking operation
Date: Tue, 22 Oct 2019 16:15:50 +0300	[thread overview]
Message-ID: <20191022131550.GA4249@mwanda> (raw)

Hello Tadeusz Struk,

The patch 9e1b74a63f77: "tpm: add support for nonblocking operation"
from Sep 10, 2018, leads to the following static checker warning:

	drivers/char/tpm/tpm-dev-common.c:222 tpm_common_write()
	warn: inconsistent returns 'priv->chip->tpm_mutex'.

drivers/char/tpm/tpm-dev-common.c
   184  
   185          /* atomic tpm command send and result receive. We only hold the ops
   186           * lock during this period so that the tpm can be unregistered even if
   187           * the char dev is held open.
   188           */
   189          if (tpm_try_get_ops(priv->chip)) {
   190                  ret = -EPIPE;
   191                  goto out;
   192          }
   193  
   194          priv->response_length = 0;
   195          priv->response_read = false;
   196          *off = 0;
   197  
   198          /*
   199           * If in nonblocking mode schedule an async job to send
   200           * the command return the size.
   201           * In case of error the err code will be returned in
   202           * the subsequent read call.
   203           */
   204          if (file->f_flags & O_NONBLOCK) {
   205                  priv->command_enqueued = true;
   206                  queue_work(tpm_dev_wq, &priv->async_work);
   207                  mutex_unlock(&priv->buffer_mutex);
   208                  return size;
                        ^^^^^^^^^^^
Don't we need to do a tpm_put_ops(priv->chip) before returning?

   209          }
   210  
   211          ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer,
   212                                 sizeof(priv->data_buffer));
   213          tpm_put_ops(priv->chip);
   214  
   215          if (ret > 0) {
   216                  priv->response_length = ret;
   217                  mod_timer(&priv->user_read_timer, jiffies + (120 * HZ));
   218                  ret = size;
   219          }
   220  out:
   221          mutex_unlock(&priv->buffer_mutex);
   222          return ret;
   223  }

regards,
dan carpenter

                 reply	other threads:[~2019-10-22 13:18 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=20191022131550.GA4249@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=tadeusz.struk@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).