Skip to content

Commit

Permalink
kernel/umh.c: optimize 'proc_cap_handler()'
Browse files Browse the repository at this point in the history
If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Christophe JAILLET <[email protected]>
Acked-by: Luis R. Rodriguez <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
tititiou36 authored and torvalds committed Nov 18, 2017
1 parent 4ca59b1 commit 8c703d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/umh.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,14 @@ static int proc_cap_handler(struct ctl_table *table, int write,
/*
* Drop everything not in the new_cap (but don't add things)
*/
spin_lock(&umh_sysctl_lock);
if (write) {
spin_lock(&umh_sysctl_lock);
if (table->data == CAP_BSET)
usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
if (table->data == CAP_PI)
usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
spin_unlock(&umh_sysctl_lock);
}
spin_unlock(&umh_sysctl_lock);

return 0;
}
Expand Down

0 comments on commit 8c703d6

Please sign in to comment.