[ammarfaizi2-block:dhowells/linux-fs/netfs-maple 35/40] fs/netfs/buffered_write.c:793 netfs_page_mkwrite() error: uninitialized symbol 'spare_region'.

From: Dan Carpenter
Date: Tue Apr 05 2022 - 20:59:58 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-m001 (https://download.01.org/0day-ci/archive/20220405/202204051945.mr2bveSZ-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
fs/netfs/buffered_write.c:793 netfs_page_mkwrite() error: uninitialized symbol 'spare_region'.

vim +/spare_region +793 fs/netfs/buffered_write.c

fc20927bc97095 David Howells 2022-02-15 732 vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf)
fc20927bc97095 David Howells 2022-02-15 733 {
fc20927bc97095 David Howells 2022-02-15 734 struct netfs_dirty_region *spare_region;
fc20927bc97095 David Howells 2022-02-15 735 struct folio *folio = page_folio(vmf->page);
fc20927bc97095 David Howells 2022-02-15 736 struct file *file = vmf->vma->vm_file;
fc20927bc97095 David Howells 2022-02-15 737 struct inode *inode = file_inode(file);
fc20927bc97095 David Howells 2022-02-15 738 struct netfs_i_context *ctx = netfs_i_context(inode);
fc20927bc97095 David Howells 2022-02-15 739 vm_fault_t ret = VM_FAULT_RETRY;
fc20927bc97095 David Howells 2022-02-15 740 int err;
fc20927bc97095 David Howells 2022-02-15 741
fc20927bc97095 David Howells 2022-02-15 742 MA_STATE(mas, &ctx->dirty_regions, vmf->page->index, PAGE_SIZE);
fc20927bc97095 David Howells 2022-02-15 743
fc20927bc97095 David Howells 2022-02-15 744 _enter("%lx", folio->index);
fc20927bc97095 David Howells 2022-02-15 745
fc20927bc97095 David Howells 2022-02-15 746 if (ctx->ops->validate_for_write(inode, file) < 0)
fc20927bc97095 David Howells 2022-02-15 747 return VM_FAULT_SIGBUS;
fc20927bc97095 David Howells 2022-02-15 748
fc20927bc97095 David Howells 2022-02-15 749 sb_start_pagefault(inode->i_sb);
fc20927bc97095 David Howells 2022-02-15 750
fc20927bc97095 David Howells 2022-02-15 751 if (folio_wait_writeback_killable(folio))
fc20927bc97095 David Howells 2022-02-15 752 goto out;
fc20927bc97095 David Howells 2022-02-15 753
fc20927bc97095 David Howells 2022-02-15 754 if (folio_lock_killable(folio) < 0)
fc20927bc97095 David Howells 2022-02-15 755 goto out;
fc20927bc97095 David Howells 2022-02-15 756
fc20927bc97095 David Howells 2022-02-15 757 if (mas_expected_entries(&mas, 2) < 0) {
fc20927bc97095 David Howells 2022-02-15 758 ret = VM_FAULT_OOM;
fc20927bc97095 David Howells 2022-02-15 759 goto out;

Lot's of goto out before "sparse_region" is set.

fc20927bc97095 David Howells 2022-02-15 760 }
fc20927bc97095 David Howells 2022-02-15 761
fc20927bc97095 David Howells 2022-02-15 762 spare_region = netfs_alloc_dirty_region();
fc20927bc97095 David Howells 2022-02-15 763 if (IS_ERR(spare_region)) {
fc20927bc97095 David Howells 2022-02-15 764 ret = VM_FAULT_OOM;
fc20927bc97095 David Howells 2022-02-15 765 goto out;
fc20927bc97095 David Howells 2022-02-15 766 }
fc20927bc97095 David Howells 2022-02-15 767
fc20927bc97095 David Howells 2022-02-15 768 err = netfs_flush_conflicting_writes(ctx, file, folio_pos(folio),
fc20927bc97095 David Howells 2022-02-15 769 folio_size(folio), folio);
fc20927bc97095 David Howells 2022-02-15 770 switch (err) {
fc20927bc97095 David Howells 2022-02-15 771 case 0:
fc20927bc97095 David Howells 2022-02-15 772 break;
fc20927bc97095 David Howells 2022-02-15 773 case -EAGAIN:
fc20927bc97095 David Howells 2022-02-15 774 ret = VM_FAULT_RETRY;
fc20927bc97095 David Howells 2022-02-15 775 goto out;
fc20927bc97095 David Howells 2022-02-15 776 case -ENOMEM:
fc20927bc97095 David Howells 2022-02-15 777 ret = VM_FAULT_OOM;
fc20927bc97095 David Howells 2022-02-15 778 goto out;
fc20927bc97095 David Howells 2022-02-15 779 default:
fc20927bc97095 David Howells 2022-02-15 780 ret = VM_FAULT_SIGBUS;
fc20927bc97095 David Howells 2022-02-15 781 goto out;
fc20927bc97095 David Howells 2022-02-15 782 }
fc20927bc97095 David Howells 2022-02-15 783
fc20927bc97095 David Howells 2022-02-15 784 netfs_commit_folio(ctx, file, &spare_region, &mas,
fc20927bc97095 David Howells 2022-02-15 785 folio, 0, folio_size(folio));
fc20927bc97095 David Howells 2022-02-15 786 netfs_commit_region(ctx, &mas, folio_pos(folio), folio_size(folio));
fc20927bc97095 David Howells 2022-02-15 787 file_update_time(file);
fc20927bc97095 David Howells 2022-02-15 788
fc20927bc97095 David Howells 2022-02-15 789 ret = VM_FAULT_LOCKED;
fc20927bc97095 David Howells 2022-02-15 790 out:
fc20927bc97095 David Howells 2022-02-15 791 sb_end_pagefault(inode->i_sb);
fc20927bc97095 David Howells 2022-02-15 792 mas_destroy(&mas);
fc20927bc97095 David Howells 2022-02-15 @793 netfs_put_dirty_region(ctx, spare_region, netfs_region_trace_put_discard);
^^^^^^^^^^^^

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