From: Alexander Kuleshov <kuleshovmail@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>, Jan Kara <jack@suse.cz>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Alexander Kuleshov <kuleshovmail@gmail.com>
Subject: [PATCH] mm/backing-dev: Check return value of the debugfs_create_dir()
Date: Tue, 25 Aug 2015 13:54:23 +0600 [thread overview]
Message-ID: <1440489263-3547-1-git-send-email-kuleshovmail@gmail.com> (raw)
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/backing-dev.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index dac5bf5..518d26a 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -117,15 +117,21 @@ static const struct file_operations bdi_debug_stats_fops = {
static void bdi_debug_register(struct backing_dev_info *bdi, const char *name)
{
- bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root);
- bdi->debug_stats = debugfs_create_file("stats", 0444, bdi->debug_dir,
- bdi, &bdi_debug_stats_fops);
+ if (bdi_debug_root) {
+ bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root);
+ if (bdi->debug_dir)
+ bdi->debug_stats = debugfs_create_file("stats", 0444,
+ bdi->debug_dir, bdi,
+ &bdi_debug_stats_fops);
+ }
}
static void bdi_debug_unregister(struct backing_dev_info *bdi)
{
- debugfs_remove(bdi->debug_stats);
- debugfs_remove(bdi->debug_dir);
+ if (bdi_debug_root) {
+ debugfs_remove(bdi->debug_stats);
+ debugfs_remove(bdi->debug_dir);
+ }
}
#else
static inline void bdi_debug_init(void)
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-08-25 7:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-25 7:54 Alexander Kuleshov [this message]
2015-08-25 8:32 ` Jan Kara
2015-08-25 21:08 ` Andrew Morton
2015-08-26 9:23 ` Jan Kara
2015-08-26 10:11 ` Alexander Kuleshov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440489263-3547-1-git-send-email-kuleshovmail@gmail.com \
--to=kuleshovmail@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox