Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1212800 > unrolled thread

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

Started byAlexander Kuleshov <kuleshovmail@gmail.com>
First post2015-08-25 10:20 +0200
Last post2015-08-27 17:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm/cma_debug: Check return value of the debugfs_create_dir() Alexander Kuleshov <kuleshovmail@gmail.com> - 2015-08-25 10:20 +0200
    Re: [PATCH] mm/cma_debug: Check return value of the debugfs_create_dir() Michal Nazarewicz <mina86@mina86.com> - 2015-08-27 17:40 +0200

#1212800 — [PATCH] mm/cma_debug: Check return value of the debugfs_create_dir()

FromAlexander Kuleshov <kuleshovmail@gmail.com>
Date2015-08-25 10:20 +0200
Subject[PATCH] mm/cma_debug: Check return value of the debugfs_create_dir()
Message-ID<q1hCz-P0-41@gated-at.bofh.it>
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 <kuleshovmail@gmail.com>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1214658

FromMichal Nazarewicz <mina86@mina86.com>
Date2015-08-27 17:40 +0200
Message-ID<q27rr-8j-17@gated-at.bofh.it>
In reply to#1212800
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 <kuleshovmail@gmail.com>

I’d also add a pr_warn but otherwise:

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  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 +--<mpn@google.com>--<xmpp:mina86@jabber.org>-----ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web