summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Gang <xili_gchen_5257@hotmail.com>2015-11-06 03:48:35 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-06 04:34:48 +0100
commit1e3ee14b9355a688ffe24725fa746ab120c42881 (patch)
treee70d8443ce609a7f88059c9e305828b19c3fc123
parentmm/mmap.c: remove redundant statement "error = -ENOMEM" (diff)
downloadlinux-1e3ee14b9355a688ffe24725fa746ab120c42881.tar.xz
linux-1e3ee14b9355a688ffe24725fa746ab120c42881.zip
mm/mmap.c: do not initialize retval in mmap_pgoff()
When fget() fails we can return -EBADF directly. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/mmap.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 28d1b3524d88..7e69f30a305e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1412,13 +1412,13 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
unsigned long, fd, unsigned long, pgoff)
{
struct file *file = NULL;
- unsigned long retval = -EBADF;
+ unsigned long retval;
if (!(flags & MAP_ANONYMOUS)) {
audit_mmap_fd(fd, flags);
file = fget(fd);
if (!file)
- goto out;
+ return -EBADF;
if (is_file_hugepages(file))
len = ALIGN(len, huge_page_size(hstate_file(file)));
retval = -EINVAL;
@@ -1453,7 +1453,6 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
out_fput:
if (file)
fput(file);
-out:
return retval;
}