]> err.no Git - linux-2.6/commitdiff
[PATCH] edac_mc: fix error handling
authorAkinobu Mita <akinobu.mita@gmail.com>
Fri, 3 Nov 2006 06:07:10 +0000 (22:07 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 3 Nov 2006 20:27:57 +0000 (12:27 -0800)
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>
drivers/edac/edac_mc.c

index 4bde30bb3be70c48e16923405bd1609386be9f62..75e9e38330ff4d4de4785ba116c7c2cd20fb6f4d 100644 (file)
@@ -230,34 +230,43 @@ 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) {
-               /* Init the MC's kobject */
-               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) {
+               debugf1("%s() error=%d\n", __func__, err);
+               return err;
+       }
 
-               /* generate sysfs "..../edac/mc"   */
-               err = kobject_set_name(&edac_memctrl_kobj,"mc");
+       /* Init the MC's kobject */
+       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) {
-                       /* FIXME: maybe new sysdev_create_subdir() */
-                       err = kobject_register(&edac_memctrl_kobj);
+       /* generate sysfs "..../edac/mc"   */
+       err = kobject_set_name(&edac_memctrl_kobj,"mc");
 
-                       if (err)
-                               debugf1("Failed to register '.../edac/mc'\n");
-                       else
-                               debugf1("Registered '.../edac/mc' kobject\n");
-               }
-       } else
-               debugf1("%s() error=%d\n", __func__, err);
+       if (err)
+               goto fail;
+
+       /* FIXME: maybe new sysdev_create_subdir() */
+       err = kobject_register(&edac_memctrl_kobj);
+
+       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;
 }