Skip to content

Commit 58c1b5b

Browse files
hkamezawaLinus Torvalds
authored andcommitted
[PATCH] memory hotadd fixes: find_next_system_ram catch range fix
find_next_system_ram() is used to find available memory resource at onlining newly added memory. This patch fixes following problem. find_next_system_ram() cannot catch this case. Resource: (start)-------------(end) Section : (start)-------------(end) Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Keith Mannthey <kmannth@gmail.com> Cc: Yasunori Goto <y-goto@jp.fujitsu.com> Cc: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 0f04ab5 commit 58c1b5b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

kernel/resource.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ int find_next_system_ram(struct resource *res)
244244

245245
start = res->start;
246246
end = res->end;
247+
BUG_ON(start >= end);
247248

248249
read_lock(&resource_lock);
249250
for (p = iomem_resource.child; p ; p = p->sibling) {
@@ -254,7 +255,7 @@ int find_next_system_ram(struct resource *res)
254255
p = NULL;
255256
break;
256257
}
257-
if (p->start >= start)
258+
if ((p->end >= start) && (p->start < end))
258259
break;
259260
}
260261
read_unlock(&resource_lock);

mm/memory_hotplug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
163163
res.flags = IORESOURCE_MEM; /* we just need system ram */
164164
section_end = res.end;
165165

166-
while (find_next_system_ram(&res) >= 0) {
166+
while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) {
167167
start_pfn = (unsigned long)(res.start >> PAGE_SHIFT);
168168
nr_pages = (unsigned long)
169169
((res.end + 1 - res.start) >> PAGE_SHIFT);

0 commit comments

Comments
 (0)