[PATCH] edac_mc: fix error handling

Call sysdev_class_unregister() on failure in edac_sysfs_memctrl_setup()
and decrease identation level for clear logic.

Acked-by: Doug Thompson <norsk5@xmission.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Akinobu Mita 2006-11-02 22:07:10 -08:00 committed by Linus Torvalds
parent 7011774db8
commit 77d6e1397a
1 changed files with 29 additions and 20 deletions

View File

@ -230,14 +230,18 @@ static struct kobj_type ktype_memctrl = {
*/
static int edac_sysfs_memctrl_setup(void)
{
int err=0;
int err = 0;
debugf1("%s()\n", __func__);
/* create the /sys/devices/system/edac directory */
err = sysdev_class_register(&edac_class);
if (!err) {
if (err) {
debugf1("%s() error=%d\n", __func__, err);
return err;
}
/* Init the MC's kobject */
memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
edac_memctrl_kobj.parent = &edac_class.kset.kobj;
@ -246,18 +250,23 @@ static int edac_sysfs_memctrl_setup(void)
/* generate sysfs "..../edac/mc" */
err = kobject_set_name(&edac_memctrl_kobj,"mc");
if (!err) {
if (err)
goto fail;
/* FIXME: maybe new sysdev_create_subdir() */
err = kobject_register(&edac_memctrl_kobj);
if (err)
if (err) {
debugf1("Failed to register '.../edac/mc'\n");
else
debugf1("Registered '.../edac/mc' kobject\n");
goto fail;
}
} else
debugf1("%s() error=%d\n", __func__, err);
debugf1("Registered '.../edac/mc' kobject\n");
return 0;
fail:
sysdev_class_unregister(&edac_class);
return err;
}