diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2017-11-17 15:27:32 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-17 16:10:01 -0800 |
commit | 8c703d660450c4df72ff24f79a335dc7973a9dc8 (patch) | |
tree | e7eecbd614bbd2548d82ba66b5b28cb7e7840bf6 /kernel/umh.c | |
parent | 4ca59b14e588f873795a11cdc77a25c686a29d23 (diff) | |
download | lwn-8c703d660450c4df72ff24f79a335dc7973a9dc8.tar.gz lwn-8c703d660450c4df72ff24f79a335dc7973a9dc8.zip |
kernel/umh.c: optimize 'proc_cap_handler()'
If 'write' is 0, we can avoid a call to spin_lock/spin_unlock.
Link: http://lkml.kernel.org/r/20171020193331.7233-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/umh.c')
-rw-r--r-- | kernel/umh.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/umh.c b/kernel/umh.c index 6ff9905250ff..18e5fa4b0e71 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -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; } |