diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/memory.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 63c25601572d..5185bcff2de9 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
| @@ -27,6 +27,8 @@ | |||
| 27 | #include <asm/atomic.h> | 27 | #include <asm/atomic.h> |
| 28 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
| 29 | 29 | ||
| 30 | static DEFINE_MUTEX(mem_sysfs_mutex); | ||
| 31 | |||
| 30 | #define MEMORY_CLASS_NAME "memory" | 32 | #define MEMORY_CLASS_NAME "memory" |
| 31 | 33 | ||
| 32 | static struct sysdev_class memory_sysdev_class = { | 34 | static struct sysdev_class memory_sysdev_class = { |
| @@ -484,6 +486,8 @@ static int add_memory_block(int nid, struct mem_section *section, | |||
| 484 | if (!mem) | 486 | if (!mem) |
| 485 | return -ENOMEM; | 487 | return -ENOMEM; |
| 486 | 488 | ||
| 489 | mutex_lock(&mem_sysfs_mutex); | ||
| 490 | |||
| 487 | mem->phys_index = __section_nr(section); | 491 | mem->phys_index = __section_nr(section); |
| 488 | mem->state = state; | 492 | mem->state = state; |
| 489 | mutex_init(&mem->state_mutex); | 493 | mutex_init(&mem->state_mutex); |
| @@ -504,6 +508,7 @@ static int add_memory_block(int nid, struct mem_section *section, | |||
| 504 | ret = register_mem_sect_under_node(mem, nid); | 508 | ret = register_mem_sect_under_node(mem, nid); |
| 505 | } | 509 | } |
| 506 | 510 | ||
| 511 | mutex_unlock(&mem_sysfs_mutex); | ||
| 507 | return ret; | 512 | return ret; |
| 508 | } | 513 | } |
| 509 | 514 | ||
| @@ -512,6 +517,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
| 512 | { | 517 | { |
| 513 | struct memory_block *mem; | 518 | struct memory_block *mem; |
| 514 | 519 | ||
| 520 | mutex_lock(&mem_sysfs_mutex); | ||
| 515 | mem = find_memory_block(section); | 521 | mem = find_memory_block(section); |
| 516 | unregister_mem_sect_under_nodes(mem); | 522 | unregister_mem_sect_under_nodes(mem); |
| 517 | mem_remove_simple_file(mem, phys_index); | 523 | mem_remove_simple_file(mem, phys_index); |
| @@ -520,6 +526,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
| 520 | mem_remove_simple_file(mem, removable); | 526 | mem_remove_simple_file(mem, removable); |
| 521 | unregister_memory(mem, section); | 527 | unregister_memory(mem, section); |
| 522 | 528 | ||
| 529 | mutex_unlock(&mem_sysfs_mutex); | ||
| 523 | return 0; | 530 | return 0; |
| 524 | } | 531 | } |
| 525 | 532 | ||
