LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Luiz Fernando N. Capitulino" <lcapitulino@mandriva.com.br>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: PATCH: __bprm_mm_init(): remove uneeded goto
Date: Tue, 4 Nov 2008 14:03:14 -0200	[thread overview]
Message-ID: <20081104140314.1b196764@doriath.conectiva> (raw)


It is only really used if insert_vm_struct() fails, we can inline it
and drop some (uneeded) lines of code.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>

---
 fs/exec.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Index: linux-2.6/fs/exec.c
===================================================================
--- linux-2.6.orig/fs/exec.c
+++ linux-2.6/fs/exec.c
@@ -232,13 +232,13 @@ static void flush_arg_page(struct linux_
 
 static int __bprm_mm_init(struct linux_binprm *bprm)
 {
-	int err = -ENOMEM;
+	int err;
 	struct vm_area_struct *vma = NULL;
 	struct mm_struct *mm = bprm->mm;
 
 	bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
 	if (!vma)
-		goto err;
+		return -ENOMEM;
 
 	down_write(&mm->mmap_sem);
 	vma->vm_mm = mm;
@@ -257,7 +257,9 @@ static int __bprm_mm_init(struct linux_b
 	err = insert_vm_struct(mm, vma);
 	if (err) {
 		up_write(&mm->mmap_sem);
-		goto err;
+		kmem_cache_free(vm_area_cachep, vma);
+		bprm->vma = NULL;
+		return err;
 	}
 
 	mm->stack_vm = mm->total_vm = 1;
@@ -266,14 +268,6 @@ static int __bprm_mm_init(struct linux_b
 	bprm->p = vma->vm_end - sizeof(void *);
 
 	return 0;
-
-err:
-	if (vma) {
-		bprm->vma = NULL;
-		kmem_cache_free(vm_area_cachep, vma);
-	}
-
-	return err;
 }
 
 static bool valid_arg_len(struct linux_binprm *bprm, long len)


-- 
Luiz Fernando N. Capitulino

             reply	other threads:[~2008-11-04 16:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-04 16:03 Luiz Fernando N. Capitulino [this message]
2008-11-04 18:57 ` Andrew Morton
2008-11-04 19:14   ` Luiz Fernando N. Capitulino
2008-11-04 19:47     ` Andrew Morton
2008-11-05  2:48       ` Arjan van de Ven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081104140314.1b196764@doriath.conectiva \
    --to=lcapitulino@mandriva.com.br \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: PATCH: __bprm_mm_init(): remove uneeded goto' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).