* [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff()
@ 2015-10-05 16:24 Chen Gang
2015-10-05 16:30 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Chen Gang @ 2015-10-05 16:24 UTC (permalink / raw)
To: Andrew Morton, kirill.shutemov, riel, oleg, dave, pfeiner,
aarcange, vishnu.ps
Cc: Linux Memory, kernel mailing list
>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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff()
2015-10-05 16:24 [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff() Chen Gang
@ 2015-10-05 16:30 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2015-10-05 16:30 UTC (permalink / raw)
To: Chen Gang
Cc: Andrew Morton, kirill.shutemov, riel, dave, pfeiner, aarcange,
vishnu.ps, Linux Memory, kernel mailing list
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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-05 16:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-05 16:24 [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff() Chen Gang
2015-10-05 16:30 ` Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).