lkml.org 
[lkml]   [2015]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/backing-dev: Check return value of the debugfs_create_dir()
Date
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


\
 
 \ /
  Last update: 2015-08-25 10:21    [W:0.204 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site