Merge tag 'for-linus-20190524' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / fs / exec.c
index 2e00333..89a500b 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  linux/fs/exec.c
  *
@@ -1652,11 +1653,13 @@ int search_binary_handler(struct linux_binprm *bprm)
                if (!try_module_get(fmt->module))
                        continue;
                read_unlock(&binfmt_lock);
+
                bprm->recursion_depth++;
                retval = fmt->load_binary(bprm);
+               bprm->recursion_depth--;
+
                read_lock(&binfmt_lock);
                put_binfmt(fmt);
-               bprm->recursion_depth--;
                if (retval < 0 && !bprm->mm) {
                        /* we got to flush_old_exec() and failed after it */
                        read_unlock(&binfmt_lock);