Module Name:    src
Committed By:   maxv
Date:           Thu Oct 22 11:38:51 UTC 2015

Modified Files:
        src/sys/kern: exec_elf.c

Log Message:
Check the error code from es_setup_stack, and correctly free ep_emul_arg if
it fails.

That bug is harmless, since ep_setup_stack never fails.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/kern/exec_elf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.77 src/sys/kern/exec_elf.c:1.78
--- src/sys/kern/exec_elf.c:1.77	Sat Sep 26 16:12:24 2015
+++ src/sys/kern/exec_elf.c	Thu Oct 22 11:38:51 2015
@@ -1,11 +1,11 @@
-/*	$NetBSD: exec_elf.c,v 1.77 2015/09/26 16:12:24 maxv Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.78 2015/10/22 11:38:51 maxv Exp $	*/
 
 /*-
- * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
+ * Copyright (c) 1994, 2000, 2005, 2015 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
+ * by Christos Zoulas and Maxime Villard.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.77 2015/09/26 16:12:24 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.78 2015/10/22 11:38:51 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -801,6 +801,7 @@ exec_elf_makecmds(struct lwp *l, struct 
 		epp->ep_entryoffset = interp_offset;
 		epp->ep_entry = ap->arg_interp + interp_offset;
 		PNBUF_PUT(interp);
+		interp = NULL;
 	} else {
 		epp->ep_entry = eh->e_entry;
 		if (epp->ep_flags & EXEC_FORCEAUX) {
@@ -824,8 +825,13 @@ exec_elf_makecmds(struct lwp *l, struct 
 	NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, PAGE_SIZE, 0,
 	    epp->ep_vp, 0, VM_PROT_READ);
 #endif
+
+	error = (*epp->ep_esch->es_setup_stack)(l, epp);
+	if (error)
+		goto bad;
+
 	kmem_free(ph, phsize);
-	return (*epp->ep_esch->es_setup_stack)(l, epp);
+	return 0;
 
 bad:
 	if (interp)

Reply via email to