From: kernel test robot <lkp@intel.com>
To: Ming Lei <tom.leiming@gmail.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
Jens Axboe <axboe@kernel.dk>
Subject: [axboe:for-7.1/block 80/87] drivers/block/ublk_drv.c:5364:20: warning: result of comparison of constant 4294967296 with expression of type 'unsigned long' is always false
Date: Fri, 10 Apr 2026 19:58:24 +0800 [thread overview]
Message-ID: <202604101952.3NOzqnu9-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git for-7.1/block
head: 539fb773a3f7c07cf7fd00617f33ed4e33058d72
commit: 23b3b6f0b584b70a427d5bb826d320151890d7da [80/87] ublk: widen ublk_shmem_buf_reg.len to __u64 for 4GB buffer support
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20260410/202604101952.3NOzqnu9-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260410/202604101952.3NOzqnu9-lkp@intel.com/reproduce)
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
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604101952.3NOzqnu9-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/block/ublk_drv.c:5364:20: warning: result of comparison of constant 4294967296 with expression of type 'unsigned long' is always false [-Wtautological-constant-out-of-range-compare]
5364 | if (!size || size > UBLK_SHMEM_BUF_SIZE_MAX ||
| ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
vim +5364 drivers/block/ublk_drv.c
5326
5327 /*
5328 * Register a shared memory buffer for zero-copy I/O.
5329 * Pins pages, builds PFN maple tree, freezes/unfreezes the queue
5330 * internally. Returns buffer index (>= 0) on success.
5331 */
5332 static int ublk_ctrl_reg_buf(struct ublk_device *ub,
5333 struct ublksrv_ctrl_cmd *header)
5334 {
5335 void __user *argp = (void __user *)(unsigned long)header->addr;
5336 struct ublk_shmem_buf_reg buf_reg;
5337 unsigned long addr, size, nr_pages;
5338 struct page **pages = NULL;
5339 unsigned int gup_flags;
5340 struct gendisk *disk;
5341 struct ublk_buf *ubuf;
5342 long pinned;
5343 u32 index;
5344 int ret;
5345
5346 if (!ublk_dev_support_shmem_zc(ub))
5347 return -EOPNOTSUPP;
5348
5349 memset(&buf_reg, 0, sizeof(buf_reg));
5350 if (copy_from_user(&buf_reg, argp,
5351 min_t(size_t, header->len, sizeof(buf_reg))))
5352 return -EFAULT;
5353
5354 if (buf_reg.flags & ~UBLK_SHMEM_BUF_READ_ONLY)
5355 return -EINVAL;
5356
5357 if (buf_reg.reserved)
5358 return -EINVAL;
5359
5360 addr = buf_reg.addr;
5361 size = buf_reg.len;
5362 nr_pages = size >> PAGE_SHIFT;
5363
> 5364 if (!size || size > UBLK_SHMEM_BUF_SIZE_MAX ||
5365 !PAGE_ALIGNED(size) || !PAGE_ALIGNED(addr))
5366 return -EINVAL;
5367
5368 disk = ublk_get_disk(ub);
5369 if (!disk)
5370 return -ENODEV;
5371
5372 /* Pin pages before quiescing (may sleep) */
5373 ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL);
5374 if (!ubuf) {
5375 ret = -ENOMEM;
5376 goto put_disk;
5377 }
5378
5379 pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
5380 if (!pages) {
5381 ret = -ENOMEM;
5382 goto err_free;
5383 }
5384
5385 gup_flags = FOLL_LONGTERM;
5386 if (!(buf_reg.flags & UBLK_SHMEM_BUF_READ_ONLY))
5387 gup_flags |= FOLL_WRITE;
5388
5389 pinned = pin_user_pages_fast(addr, nr_pages, gup_flags, pages);
5390 if (pinned < 0) {
5391 ret = pinned;
5392 goto err_free_pages;
5393 }
5394 if (pinned != nr_pages) {
5395 ret = -EFAULT;
5396 goto err_unpin;
5397 }
5398 ubuf->nr_pages = nr_pages;
5399
5400 /*
5401 * Drain inflight I/O and quiesce the queue so no new requests
5402 * are dispatched while we modify the maple tree. Keep freeze
5403 * and mutex non-nested to avoid lock dependency.
5404 */
5405 ublk_quiesce_and_release(disk);
5406
5407 mutex_lock(&ub->mutex);
5408
5409 ret = xa_alloc(&ub->bufs_xa, &index, ubuf, xa_limit_16b, GFP_KERNEL);
5410 if (ret)
5411 goto err_unlock;
5412
5413 ret = __ublk_ctrl_reg_buf(ub, ubuf, pages, index, buf_reg.flags);
5414 if (ret) {
5415 xa_erase(&ub->bufs_xa, index);
5416 goto err_unlock;
5417 }
5418
5419 mutex_unlock(&ub->mutex);
5420
5421 kvfree(pages);
5422 ublk_unquiesce_and_resume(disk);
5423 ublk_put_disk(disk);
5424 return index;
5425
5426 err_unlock:
5427 mutex_unlock(&ub->mutex);
5428 ublk_unquiesce_and_resume(disk);
5429 err_unpin:
5430 unpin_user_pages(pages, pinned);
5431 err_free_pages:
5432 kvfree(pages);
5433 err_free:
5434 kfree(ubuf);
5435 put_disk:
5436 ublk_put_disk(disk);
5437 return ret;
5438 }
5439
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-04-10 11:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202604101952.3NOzqnu9-lkp@intel.com \
--to=lkp@intel.com \
--cc=axboe@kernel.dk \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=tom.leiming@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox