History

drivers/base/memory.c: prohibit offlining of memory blocks with missing sections

Commit bdee237c0343 ("x86: mm: Use 2GB memory block size on large-memory x86-64 systems") and 982792c782ef ("x86, mm: probe memory block size for generic x86 64bit") introduced large block sizes for x86. This made it possible to have multiple sections per memory block where previously, there was a only every one section per block. Since blocks consist of contiguous ranges of section, there can be holes in the blocks where sections are not present. If one attempts to offline such a block, a crash occurs since the code is not designed to deal with this. This patch is a quick fix to gaurd against the crash by not allowing blocks with non-present sections to be offlined. Addresses https://bugzilla.kernel.org/show_bug.cgi?id=107781

Seth Jennings committed 10 years ago

Commit 26bbe7e1 parent 267a4c71 file · +4 −0Browse files

Unified · Split

drivers/base/memory.c+4−0
@@ -303,6 +303,10 @@ static int memory_subsys_offline(struct device *dev) · 302 unmodified lines
303 if (mem->state == MEM_OFFLINE)303 if (mem->state == MEM_OFFLINE)
304 return 0;304 return 0;
305 305
306 /* Can't offline block with non-present sections */
307 if (mem->section_count != sections_per_block)
308 return -EINVAL;
309
306 return memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE);310 return memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE);
307}311}
308 312