Re: [PATCH v2] tpm: Rework open/close/shutdown to avoid races

From: kernel test robot
Date: Tue Dec 15 2020 - 12:14:12 EST


Hi Sergey,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on linux/master linus/master v5.10 next-20201215]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Sergey-Temerkhanov/tpm-Rework-open-close-shutdown-to-avoid-races/20201215-214304
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 93f998879cd95b3e4f2836e7b17d6d5ae035cf90
config: m68k-randconfig-r012-20201215 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/b1f6f05f320b6b609ff70567a701e12504783b02
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sergey-Temerkhanov/tpm-Rework-open-close-shutdown-to-avoid-races/20201215-214304
git checkout b1f6f05f320b6b609ff70567a701e12504783b02
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/char/tpm/tpm-dev.c: In function 'tpm_open':
>> drivers/char/tpm/tpm-dev.c:22:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
22 | int ret = 0;
| ^~~

vim +/ret +22 drivers/char/tpm/tpm-dev.c

17
18 static int tpm_open(struct inode *inode, struct file *file)
19 {
20 struct tpm_chip *chip;
21 struct file_priv *priv;
> 22 int ret = 0;
23
24 chip = container_of(inode->i_cdev, struct tpm_chip, cdev);
25
26 /* It's assured that the chip will be opened just once,
27 * by the check of the chip reference count.
28 */
29 if (atomic_fetch_inc(&chip->refcount)) {
30 dev_dbg(&chip->dev, "Another process owns this TPM\n");
31 ret = -EBUSY;
32 goto out;
33 }
34
35 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
36 if (priv == NULL) {
37 ret = -ENOMEM;
38 goto out;
39 }
40
41 tpm_common_open(file, chip, priv, NULL);
42
43 return 0;
44
45 out:
46 atomic_dec(&chip->refcount);
47 wake_up_all(&chip->waitq);
48 return -ENOMEM;
49 }
50

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip