From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932284AbcEEJow (ORCPT ); Thu, 5 May 2016 05:44:52 -0400 Received: from terminus.zytor.com ([198.137.202.10]:44396 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932246AbcEEJot (ORCPT ); Thu, 5 May 2016 05:44:49 -0400 Date: Thu, 5 May 2016 02:44:04 -0700 From: tip-bot for Davidlohr Bueso Message-ID: Cc: akpm@linux-foundation.org, Waiman.Long@hpe.com, paulmck@linux.vnet.ibm.com, mingo@kernel.org, dave@stgolabs.net, peterz@infradead.org, dbueso@suse.de, hpa@zytor.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org Reply-To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, dave@stgolabs.net, paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org, Waiman.Long@hpe.com, hpa@zytor.com, dbueso@suse.de, peterz@infradead.org In-Reply-To: <20160420041725.GC3472@linux-uzut.site> References: <20160420041725.GC3472@linux-uzut.site> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/pvqspinlock: Robustify init_qspinlock_stat() Git-Commit-ID: b96bbdde19cc56f288372d25fd5ea7af04fc1271 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b96bbdde19cc56f288372d25fd5ea7af04fc1271 Gitweb: http://git.kernel.org/tip/b96bbdde19cc56f288372d25fd5ea7af04fc1271 Author: Davidlohr Bueso AuthorDate: Tue, 19 Apr 2016 21:17:25 -0700 Committer: Ingo Molnar CommitDate: Thu, 5 May 2016 09:58:51 +0200 locking/pvqspinlock: Robustify init_qspinlock_stat() Specifically around the debugfs file creation calls, I have no idea if they could ever possibly fail, but this is core code (debug aside) so lets at least check the return value and inform anything fishy. Signed-off-by: Davidlohr Bueso Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Waiman Long Cc: Andrew Morton Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20160420041725.GC3472@linux-uzut.site Signed-off-by: Ingo Molnar --- kernel/locking/qspinlock_stat.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kernel/locking/qspinlock_stat.h b/kernel/locking/qspinlock_stat.h index 7272233..22e0253 100644 --- a/kernel/locking/qspinlock_stat.h +++ b/kernel/locking/qspinlock_stat.h @@ -212,10 +212,8 @@ static int __init init_qspinlock_stat(void) struct dentry *d_qstat = debugfs_create_dir("qlockstat", NULL); int i; - if (!d_qstat) { - pr_warn("Could not create 'qlockstat' debugfs directory\n"); - return 0; - } + if (!d_qstat) + goto out; /* * Create the debugfs files @@ -225,12 +223,20 @@ static int __init init_qspinlock_stat(void) * performance. */ for (i = 0; i < qstat_num; i++) - debugfs_create_file(qstat_names[i], 0400, d_qstat, - (void *)(long)i, &fops_qstat); + if (!debugfs_create_file(qstat_names[i], 0400, d_qstat, + (void *)(long)i, &fops_qstat)) + goto fail_undo; + + if (!debugfs_create_file(qstat_names[qstat_reset_cnts], 0200, d_qstat, + (void *)(long)qstat_reset_cnts, &fops_qstat)) + goto fail_undo; - debugfs_create_file(qstat_names[qstat_reset_cnts], 0200, d_qstat, - (void *)(long)qstat_reset_cnts, &fops_qstat); return 0; +fail_undo: + debugfs_remove_recursive(d_qstat); +out: + pr_warn("Could not create 'qlockstat' debugfs entries\n"); + return -ENOMEM; } fs_initcall(init_qspinlock_stat);