lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 10 Oct 2022 05:26:01 +0800
From:   kernel test robot <lkp@...el.com>
To:     Ira Weiny <ira.weiny@...el.com>
Cc:     kbuild-all@...ts.01.org, Ammar Faizi <ammarfaizi2@...weeb.org>,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
        linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux Memory Management List <linux-mm@...ck.org>
Subject: [ammarfaizi2-block:akpm/mm/mm-unstable 63/63] mm/highmem.c:164:7:
 warning: Local variable 'i' shadows outer variable [shadowVariable]

tree:   https://github.com/ammarfaizi2/linux-block akpm/mm/mm-unstable
head:   977bde1f5ffd252e0d4c270bc5c9489280686788
commit: 977bde1f5ffd252e0d4c270bc5c9489280686788 [63/63] highmem: fix kmap_to_page() for kmap_local_page() addresses
compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 977bde1f5ffd252e0d4c270bc5c9489280686788
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

cppcheck warnings: (new ones prefixed by >>)
>> mm/highmem.c:164:7: warning: Local variable 'i' shadows outer variable [shadowVariable]
     int i = PKMAP_NR(addr);
         ^
   mm/highmem.c:159:6: note: Shadowed declaration
    int i;
        ^
   mm/highmem.c:164:7: note: Shadow variable
     int i = PKMAP_NR(addr);
         ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   mm/highmem.c:759:13: warning: Uninitialized variable: pam->page [uninitvar]
      if (pam->page == page) {
               ^
   mm/highmem.c:796:13: warning: Uninitialized variable: pam->page [uninitvar]
      if (pam->page == page) {
               ^

vim +/i +164 mm/highmem.c

3297e760776af1 Nicolas Pitre   2009-03-04  153  
13f876ba77ebd5 Thomas Gleixner 2020-11-03  154  struct page *__kmap_to_page(void *vaddr)
5a178119b0fbe3 Mel Gorman      2012-07-31  155  {
977bde1f5ffd25 Ira Weiny       2022-10-05  156  	unsigned long base = (unsigned long) vaddr & PAGE_MASK;
977bde1f5ffd25 Ira Weiny       2022-10-05  157  	struct kmap_ctrl *kctrl = &current->kmap_ctrl;
5a178119b0fbe3 Mel Gorman      2012-07-31  158  	unsigned long addr = (unsigned long)vaddr;
977bde1f5ffd25 Ira Weiny       2022-10-05  159  	int i;
5a178119b0fbe3 Mel Gorman      2012-07-31  160  
977bde1f5ffd25 Ira Weiny       2022-10-05  161  	/* kmap() mappings */
977bde1f5ffd25 Ira Weiny       2022-10-05  162  	if (WARN_ON_ONCE(addr >= PKMAP_ADDR(0) &&
977bde1f5ffd25 Ira Weiny       2022-10-05  163  			 addr < PKMAP_ADDR(LAST_PKMAP))) {
4de22c0584fb05 Joonsoo Kim     2012-12-11 @164  		int i = PKMAP_NR(addr);
9727688dbf7ea9 songqiang       2021-05-04  165  
5a178119b0fbe3 Mel Gorman      2012-07-31  166  		return pte_page(pkmap_page_table[i]);
5a178119b0fbe3 Mel Gorman      2012-07-31  167  	}
5a178119b0fbe3 Mel Gorman      2012-07-31  168  
977bde1f5ffd25 Ira Weiny       2022-10-05  169  	/* kmap_local_page() mappings */
977bde1f5ffd25 Ira Weiny       2022-10-05  170  	if (WARN_ON_ONCE(base >= __fix_to_virt(FIX_KMAP_END) &&
977bde1f5ffd25 Ira Weiny       2022-10-05  171  			 base < __fix_to_virt(FIX_KMAP_BEGIN))) {
977bde1f5ffd25 Ira Weiny       2022-10-05  172  		for (i = 0; i < kctrl->idx; i++) {
977bde1f5ffd25 Ira Weiny       2022-10-05  173  			unsigned long base_addr;
977bde1f5ffd25 Ira Weiny       2022-10-05  174  			int idx;
977bde1f5ffd25 Ira Weiny       2022-10-05  175  
977bde1f5ffd25 Ira Weiny       2022-10-05  176  			idx = arch_kmap_local_map_idx(i, pte_pfn(pteval));
977bde1f5ffd25 Ira Weiny       2022-10-05  177  			base_addr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
977bde1f5ffd25 Ira Weiny       2022-10-05  178  
977bde1f5ffd25 Ira Weiny       2022-10-05  179  			if (base_addr == base)
977bde1f5ffd25 Ira Weiny       2022-10-05  180  				return pte_page(kctrl->pteval[i]);
977bde1f5ffd25 Ira Weiny       2022-10-05  181  		}
977bde1f5ffd25 Ira Weiny       2022-10-05  182  	}
977bde1f5ffd25 Ira Weiny       2022-10-05  183  
259ecb34e2cd73 Linus Walleij   2022-06-30  184  	return virt_to_page(vaddr);
5a178119b0fbe3 Mel Gorman      2012-07-31  185  }
13f876ba77ebd5 Thomas Gleixner 2020-11-03  186  EXPORT_SYMBOL(__kmap_to_page);
5a178119b0fbe3 Mel Gorman      2012-07-31  187  

:::::: The code at line 164 was first introduced by commit
:::::: 4de22c0584fb0566487b2cba5cdfbce346b18402 mm, highmem: use PKMAP_NR() to calculate an index of pkmap

:::::: TO: Joonsoo Kim <js1304@...il.com>
:::::: CC: Linus Torvalds <torvalds@...ux-foundation.org>

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ