[ammarfaizi2-block:dhowells/linux-fs/netfs-maple 35/40] fs/netfs/buffered_write.c:757:6: warning: variable 'spare_region' is used uninitialized whenever 'if' condition is true
From: kernel test robot
Date: Tue Apr 05 2022 - 01:41:53 EST
tree: https://github.com/ammarfaizi2/linux-block dhowells/linux-fs/netfs-maple
head: 674eea41fc70a740ff83ec590f9833f805852464
commit: fc20927bc9709523b2a53feee2a52423b9d66456 [35/40] netfs: Allow buffered shared-writeable mmap through netfs_page_mkwrite()
config: x86_64-randconfig-a005 (https://download.01.org/0day-ci/archive/20220405/202204051308.qn1GUtl6-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
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/ammarfaizi2/linux-block/commit/fc20927bc9709523b2a53feee2a52423b9d66456
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block dhowells/linux-fs/netfs-maple
git checkout fc20927bc9709523b2a53feee2a52423b9d66456
# 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=x86_64 SHELL=/bin/bash fs/netfs/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All warnings (new ones prefixed by >>):
>> fs/netfs/buffered_write.c:757:6: warning: variable 'spare_region' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (mas_expected_entries(&mas, 2) < 0) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/netfs/buffered_write.c:793:30: note: uninitialized use occurs here
netfs_put_dirty_region(ctx, spare_region, netfs_region_trace_put_discard);
^~~~~~~~~~~~
fs/netfs/buffered_write.c:757:2: note: remove the 'if' if its condition is always false
if (mas_expected_entries(&mas, 2) < 0) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/netfs/buffered_write.c:754:6: warning: variable 'spare_region' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (folio_lock_killable(folio) < 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/netfs/buffered_write.c:793:30: note: uninitialized use occurs here
netfs_put_dirty_region(ctx, spare_region, netfs_region_trace_put_discard);
^~~~~~~~~~~~
fs/netfs/buffered_write.c:754:2: note: remove the 'if' if its condition is always false
if (folio_lock_killable(folio) < 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/netfs/buffered_write.c:751:6: warning: variable 'spare_region' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (folio_wait_writeback_killable(folio))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/netfs/buffered_write.c:793:30: note: uninitialized use occurs here
netfs_put_dirty_region(ctx, spare_region, netfs_region_trace_put_discard);
^~~~~~~~~~~~
fs/netfs/buffered_write.c:751:2: note: remove the 'if' if its condition is always false
if (folio_wait_writeback_killable(folio))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/netfs/buffered_write.c:734:41: note: initialize the variable 'spare_region' to silence this warning
struct netfs_dirty_region *spare_region;
^
= NULL
3 warnings generated.
vim +757 fs/netfs/buffered_write.c
727
728 /*
729 * Notification that a previously read-only page is about to become writable.
730 * Note that the caller indicates a single page of a multipage folio.
731 */
732 vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf)
733 {
734 struct netfs_dirty_region *spare_region;
735 struct folio *folio = page_folio(vmf->page);
736 struct file *file = vmf->vma->vm_file;
737 struct inode *inode = file_inode(file);
738 struct netfs_i_context *ctx = netfs_i_context(inode);
739 vm_fault_t ret = VM_FAULT_RETRY;
740 int err;
741
742 MA_STATE(mas, &ctx->dirty_regions, vmf->page->index, PAGE_SIZE);
743
744 _enter("%lx", folio->index);
745
746 if (ctx->ops->validate_for_write(inode, file) < 0)
747 return VM_FAULT_SIGBUS;
748
749 sb_start_pagefault(inode->i_sb);
750
751 if (folio_wait_writeback_killable(folio))
752 goto out;
753
754 if (folio_lock_killable(folio) < 0)
755 goto out;
756
> 757 if (mas_expected_entries(&mas, 2) < 0) {
--
0-DAY CI Kernel Test Service
https://01.org/lkp