Re: [PATCH] eventfd: use a generic helper instead of an open coded wait_event

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

 



Hi,

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/wenyang-linux-foxmail-com/eventfd-use-a-generic-helper-instead-of-an-open-coded-wait_event/20221222-234947
patch link:    https://lore.kernel.org/r/tencent_B38979DE0FF3B9B3EA887A37487B123BBD05%40qq.com
patch subject: [PATCH] eventfd: use a generic helper instead of an open coded wait_event
config: i386-randconfig-m021
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>

smatch warnings:
fs/eventfd.c:254 eventfd_read() warn: inconsistent returns '&ctx->wqh.lock'.

vim +254 fs/eventfd.c

12aceb89b0bce1 Jens Axboe     2020-05-01  226  static ssize_t eventfd_read(struct kiocb *iocb, struct iov_iter *to)
e1ad7468c77ddb Davide Libenzi 2007-05-10  227  {
12aceb89b0bce1 Jens Axboe     2020-05-01  228  	struct file *file = iocb->ki_filp;
b6364572d641c8 Eric Biggers   2018-01-06  229  	struct eventfd_ctx *ctx = file->private_data;
b6364572d641c8 Eric Biggers   2018-01-06  230  	__u64 ucnt = 0;
e1ad7468c77ddb Davide Libenzi 2007-05-10  231  
12aceb89b0bce1 Jens Axboe     2020-05-01  232  	if (iov_iter_count(to) < sizeof(ucnt))
b6364572d641c8 Eric Biggers   2018-01-06  233  		return -EINVAL;
d48eb233159522 Davide Libenzi 2007-05-18  234  	spin_lock_irq(&ctx->wqh.lock);
12aceb89b0bce1 Jens Axboe     2020-05-01  235  	if (!ctx->count) {
12aceb89b0bce1 Jens Axboe     2020-05-01  236  		if ((file->f_flags & O_NONBLOCK) ||
12aceb89b0bce1 Jens Axboe     2020-05-01  237  		    (iocb->ki_flags & IOCB_NOWAIT)) {
12aceb89b0bce1 Jens Axboe     2020-05-01  238  			spin_unlock_irq(&ctx->wqh.lock);
12aceb89b0bce1 Jens Axboe     2020-05-01  239  			return -EAGAIN;
12aceb89b0bce1 Jens Axboe     2020-05-01  240  		}
c908f8e6a3a1eb Wen Yang       2022-12-22  241  
c908f8e6a3a1eb Wen Yang       2022-12-22  242  		if (wait_event_interruptible_locked_irq(ctx->wqh, ctx->count))
12aceb89b0bce1 Jens Axboe     2020-05-01  243  			return -ERESTARTSYS;

spin_unlock_irq(&ctx->wqh.lock);

e1ad7468c77ddb Davide Libenzi 2007-05-10  244  	}
b6364572d641c8 Eric Biggers   2018-01-06  245  	eventfd_ctx_do_read(ctx, &ucnt);
9f0deaa12d832f Dylan Yudaken  2022-08-16  246  	current->in_eventfd = 1;
e1ad7468c77ddb Davide Libenzi 2007-05-10  247  	if (waitqueue_active(&ctx->wqh))
a9a08845e9acbd Linus Torvalds 2018-02-11  248  		wake_up_locked_poll(&ctx->wqh, EPOLLOUT);
9f0deaa12d832f Dylan Yudaken  2022-08-16  249  	current->in_eventfd = 0;
d48eb233159522 Davide Libenzi 2007-05-18  250  	spin_unlock_irq(&ctx->wqh.lock);
12aceb89b0bce1 Jens Axboe     2020-05-01  251  	if (unlikely(copy_to_iter(&ucnt, sizeof(ucnt), to) != sizeof(ucnt)))
b6364572d641c8 Eric Biggers   2018-01-06  252  		return -EFAULT;
cb289d6244a37c Davide Libenzi 2010-01-13  253  
12aceb89b0bce1 Jens Axboe     2020-05-01 @254  	return sizeof(ucnt);
cb289d6244a37c Davide Libenzi 2010-01-13  255  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux