mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: David Howells <dhowells@redhat.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Steve French <stfrench@microsoft.com>
Subject: fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned 'npages' is never less than zero.
Date: Sun, 26 Feb 2023 11:24:48 +0800	[thread overview]
Message-ID: <202302261115.P3TQi1ZO-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   1ec35eadc3b448c91a6b763371a7073444e95f9d
commit: 0185846975339a5c348373aa450a977f5242366b netfs: Add a function to extract an iterator into a scatterlist
date:   5 days ago
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20230226/202302261115.P3TQi1ZO-lkp@intel.com/config)
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@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202302261115.P3TQi1ZO-lkp@intel.com/

smatch warnings:
fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned 'npages' is never less than zero.
fs/netfs/iterator.c:139 netfs_extract_user_to_sg() warn: unsigned 'npages' is never less than zero.

vim +/npages +139 fs/netfs/iterator.c

   106	
   107	/*
   108	 * Extract and pin a list of up to sg_max pages from UBUF- or IOVEC-class
   109	 * iterators, and add them to the scatterlist.
   110	 */
   111	static ssize_t netfs_extract_user_to_sg(struct iov_iter *iter,
   112						ssize_t maxsize,
   113						struct sg_table *sgtable,
   114						unsigned int sg_max,
   115						iov_iter_extraction_t extraction_flags)
   116	{
   117		struct scatterlist *sg = sgtable->sgl + sgtable->nents;
   118		struct page **pages;
   119		unsigned int npages;
   120		ssize_t ret = 0, res;
   121		size_t len, off;
   122	
   123		/* We decant the page list into the tail of the scatterlist */
   124		pages = (void *)sgtable->sgl + array_size(sg_max, sizeof(struct scatterlist));
   125		pages -= sg_max;
   126	
   127		do {
   128			res = iov_iter_extract_pages(iter, &pages, maxsize, sg_max,
   129						     extraction_flags, &off);
   130			if (res < 0)
   131				goto failed;
   132	
   133			len = res;
   134			maxsize -= len;
   135			ret += len;
   136			npages = DIV_ROUND_UP(off + len, PAGE_SIZE);
   137			sg_max -= npages;
   138	
 > 139			for (; npages < 0; npages--) {
   140				struct page *page = *pages;
   141				size_t seg = min_t(size_t, PAGE_SIZE - off, len);
   142	
   143				*pages++ = NULL;
   144				sg_set_page(sg, page, len, off);
   145				sgtable->nents++;
   146				sg++;
   147				len -= seg;
   148				off = 0;
   149			}
   150		} while (maxsize > 0 && sg_max > 0);
   151	
   152		return ret;
   153	
   154	failed:
   155		while (sgtable->nents > sgtable->orig_nents)
   156			put_page(sg_page(&sgtable->sgl[--sgtable->nents]));
   157		return res;
   158	}
   159	

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

                 reply	other threads:[~2023-02-26  3:25 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=202302261115.P3TQi1ZO-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=stfrench@microsoft.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

all inboxes | Powered by JetHome®