diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2010-01-15 20:01:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-16 15:15:39 -0500 |
commit | 8ff410daa009c4b44be445ded5b0cec00abc0426 (patch) | |
tree | c8cd0a20b7116e7f150397d50b25fc626bec86dd | |
parent | ba168fc37dea145deeb8fa9e7e71c748d2e00d74 (diff) |
sysdev: fix prototype for memory_sysdev_class show/store functions
The function prototype mismatches in call stack:
[<ffffffff81494268>] print_block_size+0x58/0x60
[<ffffffff81487e3f>] sysdev_class_show+0x1f/0x30
[<ffffffff811d629b>] sysfs_read_file+0xcb/0x1f0
[<ffffffff81176328>] vfs_read+0xc8/0x180
Due to prototype mismatch, print_block_size() will sprintf() into
*attribute instead of *buf, hence user space will read the initial
zeros from *buf:
$ hexdump /sys/devices/system/memory/block_size_bytes
0000000 0000 0000 0000 0000
0000008
After patch:
cat /sys/devices/system/memory/block_size_bytes
0x8000000
This complements commits c29af9636 and 4a0b2b4dbe.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: "Zheng, Shaohui" <shaohui.zheng@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/base/memory.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index bd025059711f..ae6b6c43cff9 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -309,17 +309,19 @@ static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); | |||
309 | * Block size attribute stuff | 309 | * Block size attribute stuff |
310 | */ | 310 | */ |
311 | static ssize_t | 311 | static ssize_t |
312 | print_block_size(struct class *class, char *buf) | 312 | print_block_size(struct sysdev_class *class, |
313 | struct sysdev_class_attribute *class_attr, | ||
314 | char *buf) | ||
313 | { | 315 | { |
314 | return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); | 316 | return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); |
315 | } | 317 | } |
316 | 318 | ||
317 | static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); | 319 | static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); |
318 | 320 | ||
319 | static int block_size_init(void) | 321 | static int block_size_init(void) |
320 | { | 322 | { |
321 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, | 323 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, |
322 | &class_attr_block_size_bytes.attr); | 324 | &attr_block_size_bytes.attr); |
323 | } | 325 | } |
324 | 326 | ||
325 | /* | 327 | /* |
@@ -330,7 +332,9 @@ static int block_size_init(void) | |||
330 | */ | 332 | */ |
331 | #ifdef CONFIG_ARCH_MEMORY_PROBE | 333 | #ifdef CONFIG_ARCH_MEMORY_PROBE |
332 | static ssize_t | 334 | static ssize_t |
333 | memory_probe_store(struct class *class, const char *buf, size_t count) | 335 | memory_probe_store(struct sysdev_class *class, |
336 | struct sysdev_class_attribute *class_attr, | ||
337 | const char *buf, size_t count) | ||
334 | { | 338 | { |
335 | u64 phys_addr; | 339 | u64 phys_addr; |
336 | int nid; | 340 | int nid; |
@@ -346,12 +350,12 @@ memory_probe_store(struct class *class, const char *buf, size_t count) | |||
346 | 350 | ||
347 | return count; | 351 | return count; |
348 | } | 352 | } |
349 | static CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store); | 353 | static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store); |
350 | 354 | ||
351 | static int memory_probe_init(void) | 355 | static int memory_probe_init(void) |
352 | { | 356 | { |
353 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, | 357 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, |
354 | &class_attr_probe.attr); | 358 | &attr_probe.attr); |
355 | } | 359 | } |
356 | #else | 360 | #else |
357 | static inline int memory_probe_init(void) | 361 | static inline int memory_probe_init(void) |
@@ -367,7 +371,9 @@ static inline int memory_probe_init(void) | |||
367 | 371 | ||
368 | /* Soft offline a page */ | 372 | /* Soft offline a page */ |
369 | static ssize_t | 373 | static ssize_t |
370 | store_soft_offline_page(struct class *class, const char *buf, size_t count) | 374 | store_soft_offline_page(struct sysdev_class *class, |
375 | struct sysdev_class_attribute *class_attr, | ||
376 | const char *buf, size_t count) | ||
371 | { | 377 | { |
372 | int ret; | 378 | int ret; |
373 | u64 pfn; | 379 | u64 pfn; |
@@ -384,7 +390,9 @@ store_soft_offline_page(struct class *class, const char *buf, size_t count) | |||
384 | 390 | ||
385 | /* Forcibly offline a page, including killing processes. */ | 391 | /* Forcibly offline a page, including killing processes. */ |
386 | static ssize_t | 392 | static ssize_t |
387 | store_hard_offline_page(struct class *class, const char *buf, size_t count) | 393 | store_hard_offline_page(struct sysdev_class *class, |
394 | struct sysdev_class_attribute *class_attr, | ||
395 | const char *buf, size_t count) | ||
388 | { | 396 | { |
389 | int ret; | 397 | int ret; |
390 | u64 pfn; | 398 | u64 pfn; |
@@ -397,18 +405,18 @@ store_hard_offline_page(struct class *class, const char *buf, size_t count) | |||
397 | return ret ? ret : count; | 405 | return ret ? ret : count; |
398 | } | 406 | } |
399 | 407 | ||
400 | static CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); | 408 | static SYSDEV_CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); |
401 | static CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); | 409 | static SYSDEV_CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); |
402 | 410 | ||
403 | static __init int memory_fail_init(void) | 411 | static __init int memory_fail_init(void) |
404 | { | 412 | { |
405 | int err; | 413 | int err; |
406 | 414 | ||
407 | err = sysfs_create_file(&memory_sysdev_class.kset.kobj, | 415 | err = sysfs_create_file(&memory_sysdev_class.kset.kobj, |
408 | &class_attr_soft_offline_page.attr); | 416 | &attr_soft_offline_page.attr); |
409 | if (!err) | 417 | if (!err) |
410 | err = sysfs_create_file(&memory_sysdev_class.kset.kobj, | 418 | err = sysfs_create_file(&memory_sysdev_class.kset.kobj, |
411 | &class_attr_hard_offline_page.attr); | 419 | &attr_hard_offline_page.attr); |
412 | return err; | 420 | return err; |
413 | } | 421 | } |
414 | #else | 422 | #else |