From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752889AbbJEQdj (ORCPT ); Mon, 5 Oct 2015 12:33:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45535 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751619AbbJEQdi (ORCPT ); Mon, 5 Oct 2015 12:33:38 -0400 Date: Mon, 5 Oct 2015 18:30:21 +0200 From: Oleg Nesterov To: Chen Gang Cc: Andrew Morton , "kirill.shutemov@linux.intel.com" , "riel@redhat.com" , "dave@stgolabs.net" , "pfeiner@google.com" , "aarcange@redhat.com" , "vishnu.ps@samsung.com" , Linux Memory , kernel mailing list Subject: Re: [PATCH] mm/mmap.c: Do not initialize retval in mmap_pgoff() Message-ID: <20151005163021.GB19857@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Oleg Nesterov > --- 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 > >