Merge branch 'for-2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
[cascardo/linux.git] / fs / ocfs2 / cluster / heartbeat.c
index 892e2de..9e3d45b 100644 (file)
@@ -1963,8 +1963,10 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
        if (reg == NULL)
                return ERR_PTR(-ENOMEM);
 
-       if (strlen(name) > O2HB_MAX_REGION_NAME_LEN)
-               return ERR_PTR(-ENAMETOOLONG);
+       if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) {
+               ret = -ENAMETOOLONG;
+               goto free;
+       }
 
        spin_lock(&o2hb_live_lock);
        reg->hr_region_num = 0;
@@ -1973,7 +1975,8 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
                                                         O2NM_MAX_REGIONS);
                if (reg->hr_region_num >= O2NM_MAX_REGIONS) {
                        spin_unlock(&o2hb_live_lock);
-                       return ERR_PTR(-EFBIG);
+                       ret = -EFBIG;
+                       goto free;
                }
                set_bit(reg->hr_region_num, o2hb_region_bitmap);
        }
@@ -1985,10 +1988,13 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
        ret = o2hb_debug_region_init(reg, o2hb_debug_dir);
        if (ret) {
                config_item_put(&reg->hr_item);
-               return ERR_PTR(ret);
+               goto free;
        }
 
        return &reg->hr_item;
+free:
+       kfree(reg);
+       return ERR_PTR(ret);
 }
 
 static void o2hb_heartbeat_group_drop_item(struct config_group *group,