diff options
author | Andrew Morton <akpm@osdl.org> | 2006-12-06 20:37:29 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 08:39:36 -0800 |
commit | 28ec24e23229ae3d333f8d7f0e6b31fa8ea7bf46 (patch) | |
tree | 92b1a54da4d5e4982540b7dffa9525f75005f92a /drivers/base | |
parent | 0d75565f1e8f098b80a34ccf70db450f60618ec8 (diff) | |
download | linux-3.10-28ec24e23229ae3d333f8d7f0e6b31fa8ea7bf46.tar.gz linux-3.10-28ec24e23229ae3d333f8d7f0e6b31fa8ea7bf46.tar.bz2 linux-3.10-28ec24e23229ae3d333f8d7f0e6b31fa8ea7bf46.zip |
[PATCH] driver/base/memory.c: handle errors properly
Do proper error-checking and propagation in drivers/base/memory.c, hence fix
__must_check warnings.
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/memory.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index c6b7d9c4b65..74b96795d2f 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); static int block_size_init(void) { - sysfs_create_file(&memory_sysdev_class.kset.kobj, - &class_attr_block_size_bytes.attr); - return 0; + return sysfs_create_file(&memory_sysdev_class.kset.kobj, + &class_attr_block_size_bytes.attr); } /* @@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, memory_probe_store); static int memory_probe_init(void) { - sysfs_create_file(&memory_sysdev_class.kset.kobj, - &class_attr_probe.attr); - return 0; + return sysfs_create_file(&memory_sysdev_class.kset.kobj, + &class_attr_probe.attr); } #else -#define memory_probe_init(...) do {} while (0) +static inline int memory_probe_init(void) +{ + return 0; +} #endif /* @@ -431,9 +432,12 @@ int __init memory_dev_init(void) { unsigned int i; int ret; + int err; memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; ret = sysdev_class_register(&memory_sysdev_class); + if (ret) + goto out; /* * Create entries for memory sections that were found @@ -442,11 +446,19 @@ int __init memory_dev_init(void) for (i = 0; i < NR_MEM_SECTIONS; i++) { if (!valid_section_nr(i)) continue; - add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); + err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); + if (!ret) + ret = err; } - memory_probe_init(); - block_size_init(); - + err = memory_probe_init(); + if (!ret) + ret = err; + err = block_size_init(); + if (!ret) + ret = err; +out: + if (ret) + printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret); return ret; } |