diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-04-11 03:14:46 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-04-11 03:48:12 -0400 |
commit | 7f00f388712b29005782bad7e4b25942620f3b9c (patch) | |
tree | f8b1b2f7a6ec3238171276b7c3ecac242fccc36d | |
parent | 1c99a6874133ebf4513504ef7c32ce1f532d323f (diff) |
x86/intel_rdt: Fix locking in rdtgroup_schemata_write()
The schemata lock is released before freeing the resource's temporary
tmp_cbms allocation. That's racy versus another write which allocates and
uses new temporary storage, resulting in memory leaks, freeing in use
memory, double a free or any combination of those.
Move the unlock after the release code.
Fixes: 60ec2440c63d ("x86/intel_rdt: Add schemata file")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Shaohua Li <shli@fb.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20170411071446.15241-1-jolsa@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/cpu/intel_rdt_schemata.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c index f369cb8db0d5..badd2b31a560 100644 --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c | |||
@@ -200,11 +200,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, | |||
200 | } | 200 | } |
201 | 201 | ||
202 | out: | 202 | out: |
203 | rdtgroup_kn_unlock(of->kn); | ||
204 | for_each_enabled_rdt_resource(r) { | 203 | for_each_enabled_rdt_resource(r) { |
205 | kfree(r->tmp_cbms); | 204 | kfree(r->tmp_cbms); |
206 | r->tmp_cbms = NULL; | 205 | r->tmp_cbms = NULL; |
207 | } | 206 | } |
207 | rdtgroup_kn_unlock(of->kn); | ||
208 | return ret ?: nbytes; | 208 | return ret ?: nbytes; |
209 | } | 209 | } |
210 | 210 | ||