Skip to contentSkip to conversation

mm/cma_debug: Check return value of the debugfs_create_dir()

PATCH In review Alexander Kuleshov 2 participants 2 messages Aug 25, 2015 – Aug 27, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/cma_debug: Check return value of the debugfs_create_dir()

The debugfs_create_dir() function may fail and return error. If the root directory not created, we can't create anything inside it. This patch adds check for this case.

---
 mm/cma_debug.c | 3 +++
 1 file changed, 3 insertions(+)
mm/cma_debug.c +3 -0
index f8e4b60..bfb46e2 100644
@@ -171,6 +171,9 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
 	tmp = debugfs_create_dir(name, cma_debugfs_root);
 
+	if (!tmp)
+		return;
+
 	debugfs_create_file("alloc", S_IWUSR, tmp, cma,
 				&cma_alloc_fops);
 
Signature · 7 lines
2.5.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Alexander Kuleshov

The debugfs_create_dir() function may fail and return error. If the root directory not created, we can't create anything inside it. This patch adds check for this case.

I’d also add a pr_warn but otherwise:

Quoted 18 lines
---
 mm/cma_debug.c | 3 +++
 1 file changed, 3 insertions(+)
mm/cma_debug.c +3 -0
index f8e4b60..bfb46e2 100644
@@ -171,6 +171,9 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
 	tmp = debugfs_create_dir(name, cma_debugfs_root);
 
+	if (!tmp)
+		return;
+
 	debugfs_create_file("alloc", S_IWUSR, tmp, cma,
 				&cma_alloc_fops);
 
Signature · 10 lines
Best regards,                                            _     _
.o. | Liege of Serenely Enlightened Majesty of         o' \,=./ `o
..o | Computer Science,  ミハウ “mina86” ナザレヴイツ  (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>-----ooO--(_)--Ooo--

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>