]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/madvise: fix memory leak from process_madvise
authorEric Dumazet <edumazet@google.com>
Sun, 22 Nov 2020 06:16:58 +0000 (22:16 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 22 Nov 2020 18:48:22 +0000 (10:48 -0800)
The early return in process_madvise() will produce a memory leak.

Fix it.

Fixes: ecb8ac8b1f14 ("mm/madvise: introduce process_madvise() syscall: an external memory hinting API")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.kernel.org/r/20201116155132.GA3805951@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/madvise.c

index 416a56b8e757bf3465ab13cea51e0751ade2c745..7e773f949ef9fa22a0d31481083444561ddfd3ec 100644 (file)
@@ -1231,8 +1231,6 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
                ret = total_len - iov_iter_count(&iter);
 
        mmput(mm);
-       return ret;
-
 release_task:
        put_task_struct(task);
 put_pid: