f2fs: remove debufs dir if debugfs_create_file() failed
authorYounger Liu <liuyiyang@hisense.com>
Tue, 3 Dec 2013 12:11:46 +0000 (20:11 +0800)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Mon, 23 Dec 2013 01:18:05 +0000 (10:18 +0900)
When debugfs_create_file() failed in f2fs_create_root_stats(),
debugfs_root should be remove.

Signed-off-by: Younger Liu <liuyiyang@hisense.com>
Cc: Younger Liu <younger.liucn@gmail.com>
Cc: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/debug.c

index a84b0a8e6854cd6e2faba8a84124d350378343f1..b51fb3c2a8e0aec2bbd8d0af498e2e83109c2d58 100644 (file)
@@ -340,14 +340,32 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
 
 void __init f2fs_create_root_stats(void)
 {
+       struct dentry *file;
+
        debugfs_root = debugfs_create_dir("f2fs", NULL);
-       if (debugfs_root)
-               debugfs_create_file("status", S_IRUGO, debugfs_root,
-                                        NULL, &stat_fops);
+       if (!debugfs_root)
+               goto bail;
+
+       file = debugfs_create_file("status", S_IRUGO, debugfs_root,
+                       NULL, &stat_fops);
+       if (!file)
+               goto free_debugfs_dir;
+
+       return;
+
+free_debugfs_dir:
+       debugfs_remove(debugfs_root);
+
+bail:
+       debugfs_root = NULL;
+       return;
 }
 
 void f2fs_destroy_root_stats(void)
 {
+       if (!debugfs_root)
+               return;
+
        debugfs_remove_recursive(debugfs_root);
        debugfs_root = NULL;
 }