From: Christophe JAILLET Date: Fri, 17 Nov 2017 23:27:32 +0000 (-0800) Subject: kernel/umh.c: optimize 'proc_cap_handler()' X-Git-Tag: v4.19~2135^2~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c703d660450c4df72ff24f79a335dc7973a9dc8;p=platform%2Fkernel%2Flinux-rpi.git 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 Acked-by: Luis R. Rodriguez Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/umh.c b/kernel/umh.c index 6ff9905..18e5fa4 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; }