Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755220AbbHYHyz (ORCPT ); Tue, 25 Aug 2015 03:54:55 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:33227 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751087AbbHYHyy (ORCPT ); Tue, 25 Aug 2015 03:54:54 -0400 From: Alexander Kuleshov To: Andrew Morton , Tejun Heo , Jan Kara Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexander Kuleshov Subject: [PATCH] mm/backing-dev: Check return value of the debugfs_create_dir() Date: Tue, 25 Aug 2015 13:54:23 +0600 Message-Id: <1440489263-3547-1-git-send-email-kuleshovmail@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1573 Lines: 48 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 --- 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 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/