* [akpm-mm:mm-unstable 400/415] mm/mremap.c:908:7: warning: variable 'err' is used uninitialized whenever 'if' condition is false
@ 2025-03-05 5:16 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-03-05 5:16 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: llvm, oe-kbuild-all, Andrew Morton, Linux Memory Management List
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
head: 7b6c5895bb9ac3aadddd51108b7bb3bb1c7f3110
commit: 3129f7896afb86e411c0b59a553fbb4053db4012 [400/415] mm/mremap: initial refactor of move_vma()
config: i386-buildonly-randconfig-004-20250305 (https://download.01.org/0day-ci/archive/20250305/202503051356.jJQQ0DoR-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/202503051356.jJQQ0DoR-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503051356.jJQQ0DoR-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from mm/mremap.c:11:
In file included from include/linux/mm.h:2321:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from mm/mremap.c:12:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
>> mm/mremap.c:908:7: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
908 | if (vma->vm_start != old_addr)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
mm/mremap.c:910:8: note: uninitialized use occurs here
910 | if (!err && vma->vm_end != old_addr + old_len)
| ^~~
mm/mremap.c:908:3: note: remove the 'if' if its condition is always true
908 | if (vma->vm_start != old_addr)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
909 | err = vma->vm_ops->may_split(vma, old_addr);
mm/mremap.c:895:19: note: initialize the variable 'err' to silence this warning
895 | unsigned long err;
| ^
| = 0
4 warnings generated.
vim +908 mm/mremap.c
3129f7896afb86 Lorenzo Stoakes 2025-03-03 887
3129f7896afb86 Lorenzo Stoakes 2025-03-03 888 /*
3129f7896afb86 Lorenzo Stoakes 2025-03-03 889 * Perform checks before attempting to write a VMA prior to it being
3129f7896afb86 Lorenzo Stoakes 2025-03-03 890 * moved.
3129f7896afb86 Lorenzo Stoakes 2025-03-03 891 */
3129f7896afb86 Lorenzo Stoakes 2025-03-03 892 static unsigned long prep_move_vma(struct vma_remap_struct *vrm,
3129f7896afb86 Lorenzo Stoakes 2025-03-03 893 unsigned long *vm_flags_ptr)
3129f7896afb86 Lorenzo Stoakes 2025-03-03 894 {
3129f7896afb86 Lorenzo Stoakes 2025-03-03 895 unsigned long err;
3129f7896afb86 Lorenzo Stoakes 2025-03-03 896 struct vm_area_struct *vma = vrm->vma;
3129f7896afb86 Lorenzo Stoakes 2025-03-03 897 unsigned long old_addr = vrm->addr;
3129f7896afb86 Lorenzo Stoakes 2025-03-03 898 unsigned long old_len = vrm->old_len;
^1da177e4c3f41 Linus Torvalds 2005-04-16 899
^1da177e4c3f41 Linus Torvalds 2005-04-16 900 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 901 * We'd prefer to avoid failure later on in do_munmap:
^1da177e4c3f41 Linus Torvalds 2005-04-16 902 * which may split one vma into three before unmapping.
^1da177e4c3f41 Linus Torvalds 2005-04-16 903 */
3129f7896afb86 Lorenzo Stoakes 2025-03-03 904 if (current->mm->map_count >= sysctl_max_map_count - 3)
^1da177e4c3f41 Linus Torvalds 2005-04-16 905 return -ENOMEM;
^1da177e4c3f41 Linus Torvalds 2005-04-16 906
73d5e06299195f Dmitry Safonov 2020-12-14 907 if (vma->vm_ops && vma->vm_ops->may_split) {
73d5e06299195f Dmitry Safonov 2020-12-14 @908 if (vma->vm_start != old_addr)
73d5e06299195f Dmitry Safonov 2020-12-14 909 err = vma->vm_ops->may_split(vma, old_addr);
73d5e06299195f Dmitry Safonov 2020-12-14 910 if (!err && vma->vm_end != old_addr + old_len)
73d5e06299195f Dmitry Safonov 2020-12-14 911 err = vma->vm_ops->may_split(vma, old_addr + old_len);
73d5e06299195f Dmitry Safonov 2020-12-14 912 if (err)
73d5e06299195f Dmitry Safonov 2020-12-14 913 return err;
73d5e06299195f Dmitry Safonov 2020-12-14 914 }
73d5e06299195f Dmitry Safonov 2020-12-14 915
1ff82995731667 Hugh Dickins 2009-09-21 916 /*
1ff82995731667 Hugh Dickins 2009-09-21 917 * Advise KSM to break any KSM pages in the area to be moved:
1ff82995731667 Hugh Dickins 2009-09-21 918 * it would be confusing if they were to turn up at the new
1ff82995731667 Hugh Dickins 2009-09-21 919 * location, where they happen to coincide with different KSM
1ff82995731667 Hugh Dickins 2009-09-21 920 * pages recently unmapped. But leave vma->vm_flags as it was,
1ff82995731667 Hugh Dickins 2009-09-21 921 * so KSM can come around to merge on vma and new_vma afterwards.
1ff82995731667 Hugh Dickins 2009-09-21 922 */
7103ad323b1ae3 Hugh Dickins 2009-09-21 923 err = ksm_madvise(vma, old_addr, old_addr + old_len,
3129f7896afb86 Lorenzo Stoakes 2025-03-03 924 MADV_UNMERGEABLE, vm_flags_ptr);
7103ad323b1ae3 Hugh Dickins 2009-09-21 925 if (err)
7103ad323b1ae3 Hugh Dickins 2009-09-21 926 return err;
1ff82995731667 Hugh Dickins 2009-09-21 927
3129f7896afb86 Lorenzo Stoakes 2025-03-03 928 return 0;
ad8ee77ea9db1f Dmitry Safonov 2020-12-14 929 }
ad8ee77ea9db1f Dmitry Safonov 2020-12-14 930
:::::: The code at line 908 was first introduced by commit
:::::: 73d5e06299195f4df82832cfc4a3a0c574c1e473 mremap: check if it's possible to split original vma
:::::: TO: Dmitry Safonov <dima@arista.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-05 5:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-05 5:16 [akpm-mm:mm-unstable 400/415] mm/mremap.c:908:7: warning: variable 'err' is used uninitialized whenever 'if' condition is false kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox