From: Davidlohr Bueso <dave@stgolabs.net>
To: "Long, Wai Man" <waiman.long@hpe.com>
Cc: "mingo@kernel.org" <mingo@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH -tip v3 3/3] locking/pvqspinlock: Robustify init_qspinlock_stat()
Date: Tue, 19 Apr 2016 21:17:25 -0700 [thread overview]
Message-ID: <20160420041725.GC3472@linux-uzut.site> (raw)
In-Reply-To: <CS1PR84MB0312315E60265F5E8972CACBF16C0@CS1PR84MB0312.NAMPRD84.PROD.OUTLOOK.COM>
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 <dbueso@suse.de>
---
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 72722334237a..22e025309845 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);
--
2.8.1
next prev parent reply other threads:[~2016-04-20 4:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 6:31 [PATCH -tip 1/3] locking/pvqspinlock: Fix div by 0 in qstats Davidlohr Bueso
2016-04-18 6:31 ` [PATCH -tip 2/3] locking/pvqspinlock: Avoid double resetting of stats Davidlohr Bueso
2016-04-18 19:39 ` Waiman Long
2016-05-05 9:43 ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2016-04-18 6:31 ` [PATCH -tip 3/3] locking/pvqspinlock: Robustify init_qspinlock_stat() Davidlohr Bueso
2016-04-18 16:16 ` Davidlohr Bueso
[not found] ` <CS1PR84MB0312315E60265F5E8972CACBF16C0@CS1PR84MB0312.NAMPRD84.PROD.OUTLOOK.COM>
2016-04-20 4:10 ` [PATCH -tip v2] " Davidlohr Bueso
2016-04-20 4:13 ` Davidlohr Bueso
2016-04-20 4:17 ` Davidlohr Bueso [this message]
2016-04-20 20:06 ` [PATCH -tip v3 3/3] " Waiman Long
2016-05-05 9:44 ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2016-04-18 19:40 ` [PATCH -tip 3/3] " Waiman Long
2016-04-18 19:34 ` [PATCH -tip 1/3] locking/pvqspinlock: Fix div by 0 in qstats Waiman Long
2016-04-19 9:34 ` [tip:locking/urgent] locking/pvqspinlock: Fix division by zero in qstat_read() tip-bot for Davidlohr Bueso
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=20160420041725.GC3472@linux-uzut.site \
--to=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=waiman.long@hpe.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.