Module Name:    src
Committed By:   maxv
Date:           Sun Oct 19 17:33:59 UTC 2014

Modified Files:
        src/sys/compat/linux/common: linux_uselib.c

Log Message:
Resource leak.

Found by my code scanner.

Tested by njoly@; ok njoly@ rmind@ on tech-kern@.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/compat/linux/common/linux_uselib.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/compat/linux/common/linux_uselib.c
diff -u src/sys/compat/linux/common/linux_uselib.c:1.30 src/sys/compat/linux/common/linux_uselib.c:1.31
--- src/sys/compat/linux/common/linux_uselib.c:1.30	Fri Aug 28 01:39:03 2009
+++ src/sys/compat/linux/common/linux_uselib.c	Sun Oct 19 17:33:58 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $	*/
+/*	$NetBSD: linux_uselib.c,v 1.31 2014/10/19 17:33:58 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_uselib.c,v 1.31 2014/10/19 17:33:58 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -103,17 +103,18 @@ linux_sys_uselib(struct lwp *l, const st
 	if ((error = vn_rdwr(UIO_READ, vp, (void *) &hdr, LINUX_AOUT_HDR_SIZE,
 			     0, UIO_SYSSPACE, IO_NODELOCKED, l->l_cred,
 			     &rem, NULL))) {
-		vrele(vp);
-		return error;
+		goto out;
 	}
 
 	if (rem != 0) {
-		vrele(vp);
-		return ENOEXEC;
+		error = ENOEXEC;
+		goto out;
 	}
 
-	if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE)
-		return ENOEXEC;
+	if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE) {
+		error = ENOEXEC;
+		goto out;
+	}
 
 	magic = LINUX_N_MAGIC(&hdr);
 	taddr = hdr.a_entry & (~(PAGE_SIZE - 1));
@@ -123,7 +124,7 @@ linux_sys_uselib(struct lwp *l, const st
 
 	error = vn_marktext(vp);
 	if (error)
-		return (error);
+		goto out;
 
 	vcset.evs_cnt = 0;
 	vcset.evs_used = 0;
@@ -150,7 +151,7 @@ linux_sys_uselib(struct lwp *l, const st
 
 	kill_vmcmds(&vcset);
 
+out:
 	vrele(vp);
-
 	return error;
 }

Reply via email to