Skip to content

Commit 7f00f38

Browse files
olsajiriKAGA-KOKO
authored andcommitted
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: 60ec244 ("x86/intel_rdt: Add schemata file") Signed-off-by: Jiri Olsa <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Shaohua Li <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 1c99a68 commit 7f00f38

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/cpu/intel_rdt_schemata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
200200
}
201201

202202
out:
203-
rdtgroup_kn_unlock(of->kn);
204203
for_each_enabled_rdt_resource(r) {
205204
kfree(r->tmp_cbms);
206205
r->tmp_cbms = NULL;
207206
}
207+
rdtgroup_kn_unlock(of->kn);
208208
return ret ?: nbytes;
209209
}
210210

0 commit comments

Comments
 (0)