mm/vmalloc.c:2782:58: warning: operation on 'data->idx' may be undefined

From: kernel test robot
Date: Fri Nov 05 2021 - 12:56:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7
commit: 9a8797722e4239242d0cb4cc4baa805df6ac979e Drivers: hv: vmbus: Initialize VMbus ring buffer for Isolation VM
date: 8 days ago
config: arm64-randconfig-r022-20211105 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9a8797722e4239242d0cb4cc4baa805df6ac979e
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 9a8797722e4239242d0cb4cc4baa805df6ac979e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm64

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

All warnings (new ones prefixed by >>):

In file included from arch/arm64/include/asm/kasan.h:10,
from arch/arm64/include/asm/processor.h:39,
from include/asm-generic/qrwlock.h:14,
from ./arch/arm64/include/generated/asm/qrwlock.h:1,
from arch/arm64/include/asm/spinlock.h:9,
from include/linux/spinlock.h:94,
from include/linux/vmalloc.h:5,
from mm/vmalloc.c:11:
mm/vmalloc.c: In function 'vmap_pfn_apply':
>> mm/vmalloc.c:2782:58: warning: operation on 'data->idx' may be undefined [-Wsequence-point]
2782 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
| ~~~~~~~~~^~
arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
25 | #define __pte(x) ((pte_t) { (x) } )
| ^
arch/arm64/include/asm/pgtable.h:80:15: note: in expansion of macro '__phys_to_pte_val'
80 | __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
| ^~~~~~~~~~~~~~~~~
mm/vmalloc.c:2782:30: note: in expansion of macro 'pfn_pte'
2782 | *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
| ^~~~~~~


vim +2782 mm/vmalloc.c

3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2775
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2776 static int vmap_pfn_apply(pte_t *pte, unsigned long addr, void *private)
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2777 {
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2778 struct vmap_pfn_data *data = private;
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2779
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2780 if (WARN_ON_ONCE(pfn_valid(data->pfns[data->idx])))
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2781 return -EINVAL;
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 @2782 *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2783 return 0;
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2784 }
3e9a9e256b1e1e Christoph Hellwig 2020-10-17 2785

:::::: The code at line 2782 was first introduced by commit
:::::: 3e9a9e256b1e1e6e8f19faf76fa9c37578ae35ee mm: add a vmap_pfn function

:::::: TO: Christoph Hellwig <hch@xxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip