Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1239729 > unrolled thread
| Started by | Chen Gang <xili_gchen_5257@hotmail.com> |
|---|---|
| First post | 2015-10-05 18:30 +0200 |
| Last post | 2015-10-05 18:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff() Chen Gang <xili_gchen_5257@hotmail.com> - 2015-10-05 18:30 +0200
Re: [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff() Oleg Nesterov <oleg@redhat.com> - 2015-10-05 18:40 +0200
| From | Chen Gang <xili_gchen_5257@hotmail.com> |
|---|---|
| Date | 2015-10-05 18:30 +0200 |
| Subject | [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff() |
| Message-ID | <qggOe-4bm-29@gated-at.bofh.it> |
From 71fbe2eb02be288558b62045dbf56825afb99cbb Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
Date: Tue, 6 Oct 2015 00:16:23 +0800
Subject: [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff()
When fget() fails, can return -EBADF directly.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
mm/mmap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 1da4600..33fffaf 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;
}
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2015-10-05 18:40 +0200 |
| Message-ID | <qggXT-4mO-5@gated-at.bofh.it> |
| In reply to | #1239729 |
On 10/06, Chen Gang wrote:
>
> When fget() fails, can return -EBADF directly.
To me this change actually makes the code more readable and clean.
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
> --- 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;
> }
>
> --
> 1.9.3
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web