2015-08-25 07:53:32

by Alexander Kuleshov

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Alexander Kuleshov <[email protected]>
---
mm/cma_debug.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/cma_debug.c b/mm/cma_debug.c
index f8e4b60..bfb46e2 100644
--- a/mm/cma_debug.c
+++ b/mm/cma_debug.c
@@ -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);

--
2.5.0


2015-08-27 15:38:19

by Michal Nazarewicz

[permalink] [raw]
Subject: Re: [PATCH] mm/cma_debug: Check return value of the debugfs_create_dir()

On Tue, Aug 25 2015, Alexander Kuleshov wrote:
> 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.
>
> Signed-off-by: Alexander Kuleshov <[email protected]>

I’d also add a pr_warn but otherwise:

Acked-by: Michal Nazarewicz <[email protected]>

> ---
> mm/cma_debug.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/cma_debug.c b/mm/cma_debug.c
> index f8e4b60..bfb46e2 100644
> --- a/mm/cma_debug.c
> +++ b/mm/cma_debug.c
> @@ -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);
>

--
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--