diff options
| author | Davidlohr Bueso <dave@stgolabs.net> | 2016-04-20 00:17:25 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2016-05-05 03:58:51 -0400 |
| commit | b96bbdde19cc56f288372d25fd5ea7af04fc1271 (patch) | |
| tree | f6a05e901fe3a8bbca29dff237438ba14c98c88a /kernel/locking | |
| parent | dc209a3fd73ec96d4491bcc128c3b50b0a8e8017 (diff) | |
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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Waiman Long <Waiman.Long@hpe.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160420041725.GC3472@linux-uzut.site
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/locking')
| -rw-r--r-- | kernel/locking/qspinlock_stat.h | 22 |
1 files 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) | |||
| 212 | struct dentry *d_qstat = debugfs_create_dir("qlockstat", NULL); | 212 | struct dentry *d_qstat = debugfs_create_dir("qlockstat", NULL); |
| 213 | int i; | 213 | int i; |
| 214 | 214 | ||
| 215 | if (!d_qstat) { | 215 | if (!d_qstat) |
| 216 | pr_warn("Could not create 'qlockstat' debugfs directory\n"); | 216 | goto out; |
| 217 | return 0; | ||
| 218 | } | ||
| 219 | 217 | ||
| 220 | /* | 218 | /* |
| 221 | * Create the debugfs files | 219 | * Create the debugfs files |
| @@ -225,12 +223,20 @@ static int __init init_qspinlock_stat(void) | |||
| 225 | * performance. | 223 | * performance. |
| 226 | */ | 224 | */ |
| 227 | for (i = 0; i < qstat_num; i++) | 225 | for (i = 0; i < qstat_num; i++) |
| 228 | debugfs_create_file(qstat_names[i], 0400, d_qstat, | 226 | if (!debugfs_create_file(qstat_names[i], 0400, d_qstat, |
| 229 | (void *)(long)i, &fops_qstat); | 227 | (void *)(long)i, &fops_qstat)) |
| 228 | goto fail_undo; | ||
| 229 | |||
| 230 | if (!debugfs_create_file(qstat_names[qstat_reset_cnts], 0200, d_qstat, | ||
| 231 | (void *)(long)qstat_reset_cnts, &fops_qstat)) | ||
| 232 | goto fail_undo; | ||
| 230 | 233 | ||
| 231 | debugfs_create_file(qstat_names[qstat_reset_cnts], 0200, d_qstat, | ||
| 232 | (void *)(long)qstat_reset_cnts, &fops_qstat); | ||
| 233 | return 0; | 234 | return 0; |
| 235 | fail_undo: | ||
| 236 | debugfs_remove_recursive(d_qstat); | ||
| 237 | out: | ||
| 238 | pr_warn("Could not create 'qlockstat' debugfs entries\n"); | ||
| 239 | return -ENOMEM; | ||
| 234 | } | 240 | } |
| 235 | fs_initcall(init_qspinlock_stat); | 241 | fs_initcall(init_qspinlock_stat); |
| 236 | 242 | ||
