Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sys/kern Pull up following revision(s) (requested by rmin...
details: https://anonhg.NetBSD.org/src/rev/50da55b8f8c5
branches: netbsd-6
changeset: 774099:50da55b8f8c5
user: riz <riz%NetBSD.org@localhost>
date: Thu May 17 18:12:12 2012 +0000
description:
Pull up following revision(s) (requested by rmind in ticket #246):
sys/kern/vfs_syscalls.c: revision 1.455
do_open: move pathbuf destruction to the callers, thus simplify and fix a
memory leak on error path.
diffstat:
sys/kern/vfs_syscalls.c | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diffs (92 lines):
diff -r 7781584f457a -r 50da55b8f8c5 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Thu May 17 18:10:20 2012 +0000
+++ b/sys/kern/vfs_syscalls.c Thu May 17 18:12:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.449 2012/02/12 13:12:45 martin Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.449.2.1 2012/05/17 18:12:12 riz Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.449 2012/02/12 13:12:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.449.2.1 2012/05/17 18:12:12 riz Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -1485,9 +1485,9 @@
return EINVAL;
if ((error = fd_allocfile(&fp, &indx)) != 0) {
- pathbuf_destroy(pb);
return error;
}
+
/* We're going to read cwdi->cwdi_cmask unlocked here. */
cmode = ((open_mode &~ cwdi->cwdi_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW | TRYEMULROOT, pb);
@@ -1499,18 +1499,15 @@
(error =
fd_dupopen(l->l_dupfd, &indx, flags, error)) == 0) {
*fd = indx;
- pathbuf_destroy(pb);
- return (0);
+ return 0;
}
if (error == ERESTART)
error = EINTR;
- pathbuf_destroy(pb);
return error;
}
l->l_dupfd = 0;
vp = nd.ni_vp;
- pathbuf_destroy(pb);
if ((error = open_setfp(l, fp, vp, indx, flags)))
return error;
@@ -1525,7 +1522,7 @@
fd_open(const char *path, int open_flags, int open_mode, int *fd)
{
struct pathbuf *pb;
- int oflags;
+ int error, oflags;
oflags = FFLAGS(open_flags);
if ((oflags & (FREAD | FWRITE)) == 0)
@@ -1535,7 +1532,10 @@
if (pb == NULL)
return ENOMEM;
- return do_open(curlwp, pb, open_flags, open_mode, fd);
+ error = do_open(curlwp, pb, open_flags, open_mode, fd);
+ pathbuf_destroy(pb);
+
+ return error;
}
/*
@@ -1555,18 +1555,17 @@
flags = FFLAGS(SCARG(uap, flags));
if ((flags & (FREAD | FWRITE)) == 0)
- return (EINVAL);
+ return EINVAL;
error = pathbuf_copyin(SCARG(uap, path), &pb);
if (error)
return error;
error = do_open(l, pb, SCARG(uap, flags), SCARG(uap, mode), &result);
- if (error)
- return error;
+ pathbuf_destroy(pb);
*retval = result;
- return 0;
+ return error;
}
int
Home |
Main Index |
Thread Index |
Old Index