public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dan Carpenter <[email protected]>
To: [email protected], David Howells <[email protected]>
Cc: [email protected], [email protected],
	GNU/Weeb Mailing List <[email protected]>,
	[email protected]
Subject: [ammarfaizi2-block:dhowells/linux-fs/netfs-linked-list 56/61] fs/netfs/truncate.c:177 netfs_prepare_trunc_buffers() error: uninitialized symbol 'from'.
Date: Mon, 4 Jul 2022 16:08:44 +0300	[thread overview]
Message-ID: <[email protected]> (raw)

tree:   https://github.com/ammarfaizi2/linux-block dhowells/linux-fs/netfs-linked-list
head:   ce4670495468b797b0c5927fcb661bc0da48b9ab
commit: b0af788660145c19754695953b240c9eaa311df8 [56/61] netfs: Implement truncation
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220703/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
fs/netfs/truncate.c:177 netfs_prepare_trunc_buffers() error: uninitialized symbol 'from'.
fs/netfs/truncate.c:189 netfs_prepare_trunc_buffers() error: uninitialized symbol 'to'.

vim +/from +177 fs/netfs/truncate.c

b0af788660145c David Howells 2021-09-30  144  static int netfs_prepare_trunc_buffers(struct netfs_io_request *treq)
b0af788660145c David Howells 2021-09-30  145  {
b0af788660145c David Howells 2021-09-30  146  	struct netfs_inode *ctx = netfs_inode(treq->inode);
b0af788660145c David Howells 2021-09-30  147  	struct iov_iter iter;
b0af788660145c David Howells 2021-09-30  148  	struct folio *folio;
b0af788660145c David Howells 2021-09-30  149  	unsigned long long base;
b0af788660145c David Howells 2021-09-30  150  	pgoff_t from, to, fto;
b0af788660145c David Howells 2021-09-30  151  	size_t offset, seg;
b0af788660145c David Howells 2021-09-30  152  	size_t bsize = max_t(size_t, 1UL << ctx->min_bshift, PAGE_SIZE);
b0af788660145c David Howells 2021-09-30  153  	int ret;
b0af788660145c David Howells 2021-09-30  154  
b0af788660145c David Howells 2021-09-30  155  	/* We want to hold the entire replacement block, but we round that out
b0af788660145c David Howells 2021-09-30  156  	 * to a multiple of pages.
b0af788660145c David Howells 2021-09-30  157  	 */
b0af788660145c David Howells 2021-09-30  158  	base = round_down(treq->trunc_i_size, bsize);
b0af788660145c David Howells 2021-09-30  159  	treq->start	= base;
b0af788660145c David Howells 2021-09-30  160  	treq->len	= bsize;
b0af788660145c David Howells 2021-09-30  161  	treq->first	= base / PAGE_SIZE;
b0af788660145c David Howells 2021-09-30  162  	treq->last	= (base + bsize + 1) / PAGE_SIZE;
b0af788660145c David Howells 2021-09-30  163  
b0af788660145c David Howells 2021-09-30  164  	ret = netfs_add_folios_to_buffer(&treq->buffer, treq->first, treq->last,
b0af788660145c David Howells 2021-09-30  165  					 GFP_KERNEL);
b0af788660145c David Howells 2021-09-30  166  	if (ret < 0)
b0af788660145c David Howells 2021-09-30  167  		return ret;
b0af788660145c David Howells 2021-09-30  168  
b0af788660145c David Howells 2021-09-30  169  	ret = netfs_add_folios_to_buffer(&treq->bounce, treq->first, treq->last,
b0af788660145c David Howells 2021-09-30  170  					 GFP_KERNEL);
b0af788660145c David Howells 2021-09-30  171  	if (ret < 0)
b0af788660145c David Howells 2021-09-30  172  		return ret;
b0af788660145c David Howells 2021-09-30  173  
b0af788660145c David Howells 2021-09-30  174  	/* We need to fill the buffer. */
b0af788660145c David Howells 2021-09-30  175  	iov_iter_xarray(&iter, READ, &treq->buffer, base, base + bsize);
b0af788660145c David Howells 2021-09-30  176  	do {
b0af788660145c David Howells 2021-09-30 @177  		folio = read_mapping_folio(treq->mapping, from, NULL);
                                                                                                  ^^^^
Uninitialized.  Weird that kbuild is complaining about code from 2021,
though.

b0af788660145c David Howells 2021-09-30  178  		if (IS_ERR(folio))
b0af788660145c David Howells 2021-09-30  179  			return PTR_ERR(folio);
b0af788660145c David Howells 2021-09-30  180  		if (folio->index > from ||
b0af788660145c David Howells 2021-09-30  181  		    folio->index + folio_nr_pages(folio) <= folio->index) {
b0af788660145c David Howells 2021-09-30  182  			folio_put(folio);
b0af788660145c David Howells 2021-09-30  183  			kleave("-EIO [unexpected folio %lx != %lx]", folio->index, from);
b0af788660145c David Howells 2021-09-30  184  			return -EIO;
b0af788660145c David Howells 2021-09-30  185  		}
b0af788660145c David Howells 2021-09-30  186  
b0af788660145c David Howells 2021-09-30  187  		offset = (from - folio->index);
b0af788660145c David Howells 2021-09-30  188  		fto = folio->index + folio_nr_pages(folio) - 1;
b0af788660145c David Howells 2021-09-30 @189  		seg = min(to, fto);
                                                                  ^^
Same.

b0af788660145c David Howells 2021-09-30  190  		seg = (seg - from) + 1;
b0af788660145c David Howells 2021-09-30  191  		kdebug("buf=%lx-%lx fol=%lx-%lx s=%lx@%lx",
b0af788660145c David Howells 2021-09-30  192  		       from, to, folio->index, fto, seg, offset);
b0af788660145c David Howells 2021-09-30  193  		if (copy_folio_to_iter(folio, offset * PAGE_SIZE, seg * PAGE_SIZE, &iter)) {
b0af788660145c David Howells 2021-09-30  194  			folio_put(folio);
b0af788660145c David Howells 2021-09-30  195  			kleave(" = -EIO [copy failure]");
b0af788660145c David Howells 2021-09-30  196  			return -EIO;
b0af788660145c David Howells 2021-09-30  197  		}
b0af788660145c David Howells 2021-09-30  198  
b0af788660145c David Howells 2021-09-30  199  		/* We keep the refs to discard later - we don't want read
b0af788660145c David Howells 2021-09-30  200  		 * interfering with what we're up to.
b0af788660145c David Howells 2021-09-30  201  		 */
b0af788660145c David Howells 2021-09-30  202  		from = fto;
b0af788660145c David Howells 2021-09-30  203  	} while (from < to);
b0af788660145c David Howells 2021-09-30  204  
b0af788660145c David Howells 2021-09-30  205  	/* Lock the folios and clear the uptodate flag.  Read must wait. */
b0af788660145c David Howells 2021-09-30  206  
b0af788660145c David Howells 2021-09-30  207  	/* Clear the region after the new EOF */
b0af788660145c David Howells 2021-09-30  208  	iov_iter_xarray(&iter, READ, &treq->buffer, base, base + bsize);
b0af788660145c David Howells 2021-09-30  209  	iov_iter_advance(&iter, treq->trunc_i_size - treq->start);
b0af788660145c David Howells 2021-09-30  210  	iov_iter_zero(iov_iter_count(&iter), &iter);
b0af788660145c David Howells 2021-09-30  211  	return 0;
b0af788660145c David Howells 2021-09-30  212  }

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


                 reply	other threads:[~2022-07-04 13:09 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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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