diff --git a/fs/proc/base.c b/fs/proc/base.c
index d413a138dc30f000fce7505fe723c902620ee010..eafa39a3a88cb479eaca9d164e05cc4dbca1db70 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2211,6 +2211,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
 		}
 	}
 	up_read(&mm->mmap_sem);
+	mmput(mm);
 
 	for (i = 0; i < nr_files; i++) {
 		char buf[4 * sizeof(long) + 2];	/* max: %lx-%lx\0 */
@@ -2228,7 +2229,6 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
 	}
 	if (fa)
 		flex_array_free(fa);
-	mmput(mm);
 
 out_put_task:
 	put_task_struct(task);