Skip to contentSkip to conversation

ocfs2: Fix error handling when creating debugfs root in ocfs2_init()

PATCH New Jan Kara 2 participants 2 messages Nov 6, 2014 OCFS2

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 ocfs2: Fix error handling when creating debugfs root in ocfs2_init()

Error handling if creation of root of debugfs in ocfs2_init() fails is broken. Although error code is set we fail to exit ocfs2_init() with error and thus initialization ends with success. Later when mounting a filesystem, ocfs2 debugfs entries end up being created in the root of debugfs filesystem which is confusing.

Fix the error handling to bail out.

Coverity-id: 1227009

---
 fs/ocfs2/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

This replaces patch "ocfs2: Remove pointless assignment in ocfs2_init()". Things are safer this way and when debugfs dir creation fails, something is really wrong.

fs/ocfs2/super.c +2 -1
index 93c85bc745e1..8e3ac25efb9f 100644
@@ -1622,8 +1622,9 @@ static int __init ocfs2_init(void)
 
 	ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
 	if (!ocfs2_debugfs_root) {
-		status = -EFAULT;
+		status = -ENOMEM;
 		mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
+		goto out4;
 	}
 
 	ocfs2_set_locking_protocol();
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/1 ocfs2: Fix error handling when creating debugfs root in ocfs2_init()

Looks good to me. Thanks.

Quoted 34 lines · Jan Kara

Error handling if creation of root of debugfs in ocfs2_init() fails is broken. Although error code is set we fail to exit ocfs2_init() with error and thus initialization ends with success. Later when mounting a filesystem, ocfs2 debugfs entries end up being created in the root of debugfs filesystem which is confusing.

Fix the error handling to bail out.

Coverity-id: 1227009

---
 fs/ocfs2/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

This replaces patch "ocfs2: Remove pointless assignment in ocfs2_init()". Things are safer this way and when debugfs dir creation fails, something is really wrong.

fs/ocfs2/super.c +2 -1
index 93c85bc745e1..8e3ac25efb9f 100644
@@ -1622,8 +1622,9 @@ static int __init ocfs2_init(void)
 
 	ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
 	if (!ocfs2_debugfs_root) {
-		status = -EFAULT;
+		status = -ENOMEM;
 		mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
+		goto out4;
 	}
 
 	ocfs2_set_locking_protocol();