[bug report] tpm: add support for nonblocking operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux