linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [ammarfaizi2-block:dhowells/linux-fs/netfs-linked-list 56/61] fs/netfs/truncate.c:177 netfs_prepare_trunc_buffers() error: uninitialized symbol 'from'.
@ 2022-07-04 13:08 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-07-04 13:08 UTC (permalink / raw)
  To: kbuild, David Howells
  Cc: lkp, kbuild-all, GNU/Weeb Mailing List, linux-kernel

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/202207031955.5MWchcdz-lkp@intel.com/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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-04 13:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 13:08 [ammarfaizi2-block:dhowells/linux-fs/netfs-linked-list 56/61] fs/netfs/truncate.c:177 netfs_prepare_trunc_buffers() error: uninitialized symbol 'from' Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).