[jgunthorpe:for-yishai 12/17] drivers/vfio/pci/mlx5/main.c:254:10: warning: result of comparison of constant 9223372036854775807 with expression of type 'size_t' (aka 'unsigned int') is always false

From: kernel test robot
Date: Sat Jan 29 2022 - 01:52:54 EST


tree: https://github.com/jgunthorpe/linux for-yishai
head: f63f92a10949b3ad5f769771001e82774bcef055
commit: 70ccf2dd2a78780dd3fd87a7112938ce05da498c [12/17] vfio/mlx5: Implement vfio_pci driver for mlx5 devices
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220129/202201291323.OBtyolrA-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 33b45ee44b1f32ffdbc995e6fec806271b4b3ba4)
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/jgunthorpe/linux/commit/70ccf2dd2a78780dd3fd87a7112938ce05da498c
git remote add jgunthorpe https://github.com/jgunthorpe/linux
git fetch --no-tags jgunthorpe for-yishai
git checkout 70ccf2dd2a78780dd3fd87a7112938ce05da498c
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/vfio/pci/mlx5/

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/vfio/pci/mlx5/main.c:254:10: warning: result of comparison of constant 9223372036854775807 with expression of type 'size_t' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
if (len > type_max(loff_t) || *pos < 0 ||
~~~ ^ ~~~~~~~~~~~~~~~~
1 warning generated.


vim +254 drivers/vfio/pci/mlx5/main.c

242
243 static ssize_t mlx5vf_resume_write(struct file *filp, const char __user *buf,
244 size_t len, loff_t *pos)
245 {
246 struct mlx5_vf_migration_file *migf = filp->private_data;
247 loff_t requested_length;
248 ssize_t done = 0;
249
250 if (pos)
251 return -ESPIPE;
252 pos = &filp->f_pos;
253
> 254 if (len > type_max(loff_t) || *pos < 0 ||
255 check_add_overflow((loff_t)len, *pos, &requested_length))
256 return -EINVAL;
257
258 if (requested_length > MAX_MIGRATION_SIZE)
259 return -ENOMEM;
260
261 mutex_lock(&migf->lock);
262 if (migf->disabled) {
263 done = -ENODEV;
264 goto out_unlock;
265 }
266
267 if (migf->allocated_length < requested_length) {
268 done = mlx5vf_add_migration_pages(
269 migf,
270 DIV_ROUND_UP(requested_length - migf->allocated_length,
271 PAGE_SIZE));
272 if (done)
273 goto out_unlock;
274 }
275
276 while (len) {
277 size_t page_offset;
278 struct page *page;
279 size_t page_len;
280 u8 *to_buff;
281 int ret;
282
283 page_offset = (*pos) % PAGE_SIZE;
284 page = mlx5vf_get_migration_page(migf, *pos - page_offset);
285 if (!page) {
286 if (done == 0)
287 done = -EINVAL;
288 goto out_unlock;
289 }
290
291 page_len = min_t(size_t, len, PAGE_SIZE - page_offset);
292 to_buff = kmap_local_page(page);
293 ret = copy_from_user(to_buff + page_offset, buf, page_len);
294 kunmap_local(to_buff);
295 if (ret) {
296 done = -EFAULT;
297 goto out_unlock;
298 }
299 *pos += page_len;
300 len -= page_len;
301 done += page_len;
302 buf += page_len;
303 migf->total_length += page_len;
304 }
305 out_unlock:
306 mutex_unlock(&migf->lock);
307 return done;
308 }
309

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