Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern do_ksem_open: do not leak the file descriptor on er...
details: https://anonhg.NetBSD.org/src/rev/b7e6840861a0
branches: trunk
changeset: 764159:b7e6840861a0
user: rmind <rmind%NetBSD.org@localhost>
date: Tue Apr 12 20:37:25 2011 +0000
description:
do_ksem_open: do not leak the file descriptor on error path.
sys__ksem_unlink: fix comment, release one lock ealier.
diffstat:
sys/kern/uipc_sem.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (48 lines):
diff -r 6dca0d3ef5df -r b7e6840861a0 sys/kern/uipc_sem.c
--- a/sys/kern/uipc_sem.c Tue Apr 12 19:49:48 2011 +0000
+++ b/sys/kern/uipc_sem.c Tue Apr 12 20:37:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_sem.c,v 1.30 2011/04/11 22:31:43 rmind Exp $ */
+/* $NetBSD: uipc_sem.c,v 1.31 2011/04/12 20:37:25 rmind Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.30 2011/04/11 22:31:43 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.31 2011/04/12 20:37:25 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -448,7 +448,8 @@
if ((oflag & O_CREAT) == 0) {
mutex_exit(&ksem_lock);
KASSERT(ksnew == NULL);
- return ENOENT;
+ error = ENOENT;
+ goto err;
}
/* Check for the limit locked. */
@@ -549,9 +550,10 @@
return error;
}
- /* Remove and destroy if no referenes. */
+ /* Remove from the global list. */
LIST_REMOVE(ks, ks_entry);
nsems--;
+ mutex_exit(&ksem_lock);
refcnt = ks->ks_ref;
if (refcnt) {
@@ -559,7 +561,6 @@
ks->ks_flags |= KS_UNLINKED;
}
mutex_exit(&ks->ks_lock);
- mutex_exit(&ksem_lock);
if (refcnt == 0) {
ksem_free(ks);
Home |
Main Index |
Thread Index |
Old Index