Merge tag 'renesas-dt-fixes-for-v4.15' of https://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / kernel / umh.c
index 6ff9905250ff0563713c64585a74e888de70f343..18e5fa4b0e71913087585429e561d9eb4e30b73d 100644 (file)
@@ -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;
 }