Skip to content

Commit

Permalink
x86/intel_rdt: Fix locking in rdtgroup_schemata_write()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
olsajiri authored and KAGA-KOKO committed Apr 11, 2017
1 parent 1c99a68 commit 7f00f38
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/intel_rdt_schemata.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
}

out:
rdtgroup_kn_unlock(of->kn);
for_each_enabled_rdt_resource(r) {
kfree(r->tmp_cbms);
r->tmp_cbms = NULL;
}
rdtgroup_kn_unlock(of->kn);
return ret ?: nbytes;
}

Expand Down

0 comments on commit 7f00f38

Please sign in to comment.