Skip to content

Commit

Permalink
memory hotplug: Refuse to add unaligned memory regions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anton Blanchard authored and Greg Kroah-Hartman committed Sep 26, 2011
1 parent 220c1ed commit 61b94fe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,13 @@ memory_probe_store(struct class *class, struct class_attribute *attr,
u64 phys_addr;
int nid;
int i, ret;
unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;

phys_addr = simple_strtoull(buf, NULL, 0);

if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
return -EINVAL;

for (i = 0; i < sections_per_block; i++) {
nid = memory_add_physaddr_to_nid(phys_addr);
ret = add_memory(nid, phys_addr,
Expand Down

0 comments on commit 61b94fe

Please sign in to comment.