diff options
author | Anton Blanchard <anton@samba.org> | 2011-09-14 16:26:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-26 19:21:14 -0400 |
commit | 61b94feafa1c59a1de2719d23294dea6fd4ca362 (patch) | |
tree | 989d491d284c415bb946084bee70069fa813245d /drivers/base/memory.c | |
parent | 220c1ed1bd64b26a2edcd59ca9ff031e1b880727 (diff) |
memory hotplug: Refuse to add unaligned memory regions
The sysfs memory probe interface allows unaligned regions
to be added:
# echo 0xffffff > /sys/devices/system/memory/probe
# cat /proc/iomem
00ffffff-01fffffe : System RAM
01ffffff-02fffffe : System RAM
02ffffff-03fffffe : System RAM
03ffffff-04fffffe : System RAM
04ffffff-05fffffe : System RAM
Return -EINVAL instead of creating these bad regions.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/memory.c')
-rw-r--r-- | drivers/base/memory.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 2840ed4668c1..2a0b5f1020ed 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -380,9 +380,13 @@ memory_probe_store(struct class *class, struct class_attribute *attr, | |||
380 | u64 phys_addr; | 380 | u64 phys_addr; |
381 | int nid; | 381 | int nid; |
382 | int i, ret; | 382 | int i, ret; |
383 | unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; | ||
383 | 384 | ||
384 | phys_addr = simple_strtoull(buf, NULL, 0); | 385 | phys_addr = simple_strtoull(buf, NULL, 0); |
385 | 386 | ||
387 | if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) | ||
388 | return -EINVAL; | ||
389 | |||
386 | for (i = 0; i < sections_per_block; i++) { | 390 | for (i = 0; i < sections_per_block; i++) { |
387 | nid = memory_add_physaddr_to_nid(phys_addr); | 391 | nid = memory_add_physaddr_to_nid(phys_addr); |
388 | ret = add_memory(nid, phys_addr, | 392 | ret = add_memory(nid, phys_addr, |