tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS head: 80ab23a867e779b7d5f818a57bd578a57143becb commit: 5f0e34d2aceec67c169be7599d82f0e8519c37f7 [19459/22464] mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning config: x86_64-buildonly-randconfig-003-20240523 (https://download.01.org/0day-ci/archive/20240523/202405230933.fLM0leXg-lkp@i...) compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240523/202405230933.fLM0leXg-lkp@i...)
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/202405230933.fLM0leXg-lkp@intel.com/
Note: it may well be a FALSE warning. FWIW you are at least aware of it now. http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
mm/memory_hotplug.c: In function '__remove_section': mm/memory_hotplug.c:481:23: warning: variable 'start_pfn' set but not used [-Wunused-but-set-variable] 481 | unsigned long start_pfn; | ^~~~~~~~~ mm/memory_hotplug.c: In function 'test_pages_in_a_zone':
mm/memory_hotplug.c:1278:30: warning: 'start' may be used uninitialized [-Wmaybe-uninitialized]
1278 | *valid_start = start; | ~~~~~~~~~~~~~^~~~~~~ mm/memory_hotplug.c:1245:23: note: 'start' was declared here 1245 | unsigned long start, end; | ^~~~~
vim +/start +1278 mm/memory_hotplug.c
5c755e9fd81381 Badari Pulavarty 2008-07-23 1236 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1237 /* deb88a2a19e858 Toshi Kani 2017-02-03 1238 * Confirm all pages in a range [start, end) belong to the same zone. a96dfddbcc0433 Toshi Kani 2017-02-03 1239 * When true, return its valid [start, end). 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1240 */ a96dfddbcc0433 Toshi Kani 2017-02-03 1241 int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, a96dfddbcc0433 Toshi Kani 2017-02-03 1242 unsigned long *valid_start, unsigned long *valid_end) 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1243 { 5f0f2887f4de95 Andrew Banman 2015-12-29 1244 unsigned long pfn, sec_end_pfn; a96dfddbcc0433 Toshi Kani 2017-02-03 1245 unsigned long start, end; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1246 struct zone *zone = NULL; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1247 struct page *page; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1248 int i; deb88a2a19e858 Toshi Kani 2017-02-03 1249 for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn + 1); 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1250 pfn < end_pfn; deb88a2a19e858 Toshi Kani 2017-02-03 1251 pfn = sec_end_pfn, sec_end_pfn += PAGES_PER_SECTION) { 5f0f2887f4de95 Andrew Banman 2015-12-29 1252 /* Make sure the memory section is present first */ 5f0f2887f4de95 Andrew Banman 2015-12-29 1253 if (!present_section_nr(pfn_to_section_nr(pfn))) 5f0f2887f4de95 Andrew Banman 2015-12-29 1254 continue; 5f0f2887f4de95 Andrew Banman 2015-12-29 1255 for (; pfn < sec_end_pfn && pfn < end_pfn; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1256 pfn += MAX_ORDER_NR_PAGES) { 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1257 i = 0; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1258 /* This is just a CONFIG_HOLES_IN_ZONE check.*/ 5f0f2887f4de95 Andrew Banman 2015-12-29 1259 while ((i < MAX_ORDER_NR_PAGES) && 5f0f2887f4de95 Andrew Banman 2015-12-29 1260 !pfn_valid_within(pfn + i)) 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1261 i++; d6d8c8a48291b9 zhong jiang 2017-02-24 1262 if (i == MAX_ORDER_NR_PAGES || pfn + i >= end_pfn) 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1263 continue; 65e9b09942c6df Mikhail Zaslonko 2019-02-13 1264 /* Check if we got outside of the zone */ 65e9b09942c6df Mikhail Zaslonko 2019-02-13 1265 if (zone && !zone_spans_pfn(zone, pfn + i)) 65e9b09942c6df Mikhail Zaslonko 2019-02-13 1266 return 0; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1267 page = pfn_to_page(pfn + i); 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1268 if (zone && page_zone(page) != zone) 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1269 return 0; a96dfddbcc0433 Toshi Kani 2017-02-03 1270 if (!zone) a96dfddbcc0433 Toshi Kani 2017-02-03 1271 start = pfn + i; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1272 zone = page_zone(page); a96dfddbcc0433 Toshi Kani 2017-02-03 1273 end = pfn + MAX_ORDER_NR_PAGES; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1274 } 5f0f2887f4de95 Andrew Banman 2015-12-29 1275 } deb88a2a19e858 Toshi Kani 2017-02-03 1276 a96dfddbcc0433 Toshi Kani 2017-02-03 1277 if (zone) { a96dfddbcc0433 Toshi Kani 2017-02-03 @1278 *valid_start = start; d6d8c8a48291b9 zhong jiang 2017-02-24 1279 *valid_end = min(end, end_pfn); 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1280 return 1; a96dfddbcc0433 Toshi Kani 2017-02-03 1281 } else { deb88a2a19e858 Toshi Kani 2017-02-03 1282 return 0; 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1283 } a96dfddbcc0433 Toshi Kani 2017-02-03 1284 } 0c0e6195896535 KAMEZAWA Hiroyuki 2007-10-16 1285
:::::: The code at line 1278 was first introduced by commit :::::: a96dfddbcc04336bbed50dc2b24823e45e09e80c base/memory, hotplug: fix a kernel oops in show_valid_zones()
:::::: TO: Toshi Kani toshi.kani@hpe.com :::::: CC: Linus Torvalds torvalds@linux-foundation.org