Commit 77d6e139 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

[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: default avatarDoug Thompson <norsk5@xmission.com>
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7011774d
...@@ -230,34 +230,43 @@ static struct kobj_type ktype_memctrl = { ...@@ -230,34 +230,43 @@ static struct kobj_type ktype_memctrl = {
*/ */
static int edac_sysfs_memctrl_setup(void) static int edac_sysfs_memctrl_setup(void)
{ {
int err=0; int err = 0;
debugf1("%s()\n", __func__); debugf1("%s()\n", __func__);
/* create the /sys/devices/system/edac directory */ /* create the /sys/devices/system/edac directory */
err = sysdev_class_register(&edac_class); err = sysdev_class_register(&edac_class);
if (!err) { if (err) {
/* Init the MC's kobject */ debugf1("%s() error=%d\n", __func__, err);
memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); return err;
edac_memctrl_kobj.parent = &edac_class.kset.kobj; }
edac_memctrl_kobj.ktype = &ktype_memctrl;
/* generate sysfs "..../edac/mc" */ /* Init the MC's kobject */
err = kobject_set_name(&edac_memctrl_kobj,"mc"); memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
edac_memctrl_kobj.parent = &edac_class.kset.kobj;
edac_memctrl_kobj.ktype = &ktype_memctrl;
if (!err) { /* generate sysfs "..../edac/mc" */
/* FIXME: maybe new sysdev_create_subdir() */ err = kobject_set_name(&edac_memctrl_kobj,"mc");
err = kobject_register(&edac_memctrl_kobj);
if (err) if (err)
debugf1("Failed to register '.../edac/mc'\n"); goto fail;
else
debugf1("Registered '.../edac/mc' kobject\n"); /* FIXME: maybe new sysdev_create_subdir() */
} err = kobject_register(&edac_memctrl_kobj);
} else
debugf1("%s() error=%d\n", __func__, err); if (err) {
debugf1("Failed to register '.../edac/mc'\n");
goto fail;
}
debugf1("Registered '.../edac/mc' kobject\n");
return 0;
fail:
sysdev_class_unregister(&edac_class);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment