Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern sigtimedwait: fix a memory leak (which happens sinc...
details: https://anonhg.NetBSD.org/src/rev/dcecef5e2a86
branches: trunk
changeset: 750185:dcecef5e2a86
user: rmind <rmind%NetBSD.org@localhost>
date: Sat Dec 19 18:25:54 2009 +0000
description:
sigtimedwait: fix a memory leak (which happens since newlock2 times).
Allocate ksiginfo on stack since it is safe and sigget() assumes that it is
not allocated from pool (pending signals via sigput()/sigget() "mill" should
be dynamically allocated, however). Might be useful to revisit later.
Likely the cause of PR/40750 and indirect cause of PR/39283.
diffstat:
sys/kern/sys_sig.c | 25 ++++++++-----------------
1 files changed, 8 insertions(+), 17 deletions(-)
diffs (74 lines):
diff -r c65e0abe0f15 -r dcecef5e2a86 sys/kern/sys_sig.c
--- a/sys/kern/sys_sig.c Sat Dec 19 18:06:51 2009 +0000
+++ b/sys/kern/sys_sig.c Sat Dec 19 18:25:54 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_sig.c,v 1.23 2009/03/29 17:54:12 christos Exp $ */
+/* $NetBSD: sys_sig.c,v 1.24 2009/12/19 18:25:54 rmind Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.23 2009/03/29 17:54:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.24 2009/12/19 18:25:54 rmind Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -636,7 +636,7 @@
int error, signum;
int timo = 0;
struct timespec ts, tsstart, tsnow;
- ksiginfo_t *ksi;
+ ksiginfo_t ksi;
memset(&tsstart, 0, sizeof tsstart); /* XXX gcc */
@@ -674,13 +674,6 @@
*/
sigminusset(&sigcantmask, &l->l_sigwaitset);
- /*
- * Allocate a ksi up front. We can't sleep with the mutex held.
- */
- ksi = ksiginfo_alloc(p, NULL, PR_WAITOK);
- if (ksi == NULL)
- return (ENOMEM);
-
mutex_enter(p->p_lock);
/*
@@ -692,8 +685,8 @@
goto out;
}
- if ((signum = sigget(&p->p_sigpend, ksi, 0, &l->l_sigwaitset)) == 0)
- signum = sigget(&l->l_sigpend, ksi, 0, &l->l_sigwaitset);
+ if ((signum = sigget(&p->p_sigpend, &ksi, 0, &l->l_sigwaitset)) == 0)
+ signum = sigget(&l->l_sigpend, &ksi, 0, &l->l_sigwaitset);
if (signum != 0) {
/*
@@ -706,7 +699,7 @@
/*
* Set up the sigwait list.
*/
- l->l_sigwaited = ksi;
+ l->l_sigwaited = &ksi;
LIST_INSERT_HEAD(&p->p_sigwaiters, l, l_sigwaiter);
/*
@@ -761,10 +754,8 @@
*/
out:
if (error == 0)
- error = (*put_info)(&ksi->ksi_info, SCARG(uap, info),
- sizeof(ksi->ksi_info));
-
- ksiginfo_free(ksi);
+ error = (*put_info)(&ksi.ksi_info, SCARG(uap, info),
+ sizeof(ksi.ksi_info));
return error;
}
Home |
Main Index |
Thread Index |
Old Index