Skip to content

Commit 96c804a

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm/memory-failure.c: don't access uninitialized memmaps in memory_failure()
We should check for pfn_to_online_page() to not access uninitialized memmaps. Reshuffle the code so we don't have to duplicate the error message. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Fixes: f1dd2cd ("mm, memory_hotplug: do not associate hotadded memory to zones until online") [visible after d0dc12e] Acked-by: Naoya Horiguchi <[email protected]> Cc: Michal Hocko <[email protected]> Cc: <[email protected]> [4.13+] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent aad5f69 commit 96c804a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mm/memory-failure.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,17 +1257,19 @@ int memory_failure(unsigned long pfn, int flags)
12571257
if (!sysctl_memory_failure_recovery)
12581258
panic("Memory failure on page %lx", pfn);
12591259

1260-
if (!pfn_valid(pfn)) {
1260+
p = pfn_to_online_page(pfn);
1261+
if (!p) {
1262+
if (pfn_valid(pfn)) {
1263+
pgmap = get_dev_pagemap(pfn, NULL);
1264+
if (pgmap)
1265+
return memory_failure_dev_pagemap(pfn, flags,
1266+
pgmap);
1267+
}
12611268
pr_err("Memory failure: %#lx: memory outside kernel control\n",
12621269
pfn);
12631270
return -ENXIO;
12641271
}
12651272

1266-
pgmap = get_dev_pagemap(pfn, NULL);
1267-
if (pgmap)
1268-
return memory_failure_dev_pagemap(pfn, flags, pgmap);
1269-
1270-
p = pfn_to_page(pfn);
12711273
if (PageHuge(p))
12721274
return memory_failure_hugetlb(pfn, flags);
12731275
if (TestSetPageHWPoison(p)) {

0 commit comments

Comments
 (0)