All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
Subject: drivers/staging/most/video/video.c:176:22-23: WARNING opportunity for min()
Date: Tue, 05 May 2026 18:41:07 +0800	[thread overview]
Message-ID: <202605051807.kGilkgXt-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Tiwei Bie <tiwei.btw@antgroup.com>
CC: Johannes Berg <johannes.berg@intel.com>

Hi Tiwei,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   a293ec25d59dd96309058c70df5a4dd0f889a1e4
commit: a0e2cb6a90634f3dc80f16e882a683ee5761b0b0 um: Add VFIO-based virtual PCI driver
date:   1 year ago
:::::: branch date: 12 hours ago
:::::: commit date: 1 year ago
config: um-randconfig-r061-20260505 (https://download.01.org/0day-ci/archive/20260505/202605051807.kGilkgXt-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.4.0-5) 12.4.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: a0e2cb6a9063 ("um: Add VFIO-based virtual PCI driver")
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202605051807.kGilkgXt-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> drivers/staging/most/video/video.c:176:22-23: WARNING opportunity for min()

vim +176 drivers/staging/most/video/video.c

3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  150  
1b10a0316e2d5e2 drivers/staging/most/video/video.c    Christian Gromm 2017-11-21  151  static ssize_t comp_vdev_read(struct file *filp, char __user *buf,
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  152  			      size_t count, loff_t *pos)
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  153  {
1b10a0316e2d5e2 drivers/staging/most/video/video.c    Christian Gromm 2017-11-21  154  	struct comp_fh *fh = filp->private_data;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  155  	struct most_video_dev *mdev = fh->mdev;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  156  	int ret = 0;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  157  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  158  	if (*pos)
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  159  		return -ESPIPE;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  160  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  161  	if (!mdev)
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  162  		return -ENODEV;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  163  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  164  	/* wait for the first buffer */
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  165  	if (!(filp->f_flags & O_NONBLOCK)) {
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  166  		if (wait_event_interruptible(mdev->wait_data, data_ready(mdev)))
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  167  			return -ERESTARTSYS;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  168  	}
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  169  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  170  	if (!data_ready(mdev))
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  171  		return -EAGAIN;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  172  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  173  	while (count > 0 && data_ready(mdev)) {
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  174  		struct mbo *const mbo = get_top_mbo(mdev);
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  175  		int const rem = mbo->processed_length - fh->offs;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24 @176  		int const cnt = rem < count ? rem : count;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  177  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  178  		if (copy_to_user(buf, mbo->virt_address + fh->offs, cnt)) {
8f6f9ed15d679ad drivers/staging/most/aim-v4l2/video.c Christian Gromm 2016-06-06  179  			v4l2_err(&mdev->v4l2_dev, "read: copy_to_user failed\n");
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  180  			if (!ret)
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  181  				ret = -EFAULT;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  182  			return ret;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  183  		}
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  184  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  185  		fh->offs += cnt;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  186  		count -= cnt;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  187  		buf += cnt;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  188  		ret += cnt;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  189  
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  190  		if (cnt >= rem) {
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  191  			fh->offs = 0;
e494df039df0fc7 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2016-06-06  192  			spin_lock_irq(&mdev->list_lock);
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  193  			list_del(&mbo->list);
e494df039df0fc7 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2016-06-06  194  			spin_unlock_irq(&mdev->list_lock);
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  195  			most_put_mbo(mbo);
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  196  		}
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  197  	}
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  198  	return ret;
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  199  }
3d31c0cb6c127b1 drivers/staging/most/aim-v4l2/video.c Christian Gromm 2015-07-24  200  

:::::: The code at line 176 was first introduced by commit
:::::: 3d31c0cb6c127b1d943b610065a05decf821998c Staging: most: add MOST driver's aim-v4l2 module

:::::: TO: Christian Gromm <christian.gromm@microchip.com>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

             reply	other threads:[~2026-05-05 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05 10:41 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-27 19:50 drivers/staging/most/video/video.c:176:22-23: WARNING opportunity for min() kernel test robot

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=202605051807.kGilkgXt-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=julia.lawall@inria.fr \
    --cc=oe-kbuild@lists.linux.dev \
    /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.