sa_makeupcalls: simplify code and fix an sau leak on error.
This commit is contained in:
parent
5df39bb5be
commit
d038c11b60
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_sa.c,v 1.76 2006/06/25 08:05:36 yamt Exp $ */
|
||||
/* $NetBSD: kern_sa.c,v 1.77 2006/06/25 08:08:13 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
#include "opt_multiprocessor.h"
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.76 2006/06/25 08:05:36 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.77 2006/06/25 08:08:13 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -1487,6 +1487,7 @@ sa_makeupcalls(struct lwp *l)
|
||||
|
||||
sap -= sae->sae_sasize;
|
||||
sapp -= sae->sae_sapsize;
|
||||
error = 0;
|
||||
if (i == 1 + nevents) /* interrupted sa */
|
||||
sasp = sas[2];
|
||||
else if (i <= 1) /* self_sa and event sa */
|
||||
@ -1508,23 +1509,12 @@ sa_makeupcalls(struct lwp *l)
|
||||
sa_putcachelwp(p, l2); /* PHOLD from sa_setwoken */
|
||||
SCHED_UNLOCK(s);
|
||||
|
||||
if (copyout(&e_ss->ss_captured.ss_ctx,
|
||||
e_ss->ss_captured.ss_sa.sa_context, ucsize) != 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
printf("sa_makeupcalls(%d.%d): couldn't copyout"
|
||||
" context of event LWP %d\n",
|
||||
p->p_pid, l->l_lid,
|
||||
e_ss->ss_captured.ss_sa.sa_id);
|
||||
#endif
|
||||
if (e_ss != NULL) {
|
||||
kmem_free(e_ss, sizeof(*e_ss));
|
||||
}
|
||||
sigexit(l, SIGILL);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
error = copyout(&e_ss->ss_captured.ss_ctx,
|
||||
e_ss->ss_captured.ss_sa.sa_context, ucsize);
|
||||
sasp = &e_ss->ss_captured.ss_sa;
|
||||
}
|
||||
if ((sae->sae_sacopyout != NULL &&
|
||||
if (error != 0 ||
|
||||
(sae->sae_sacopyout != NULL &&
|
||||
((*sae->sae_sacopyout)(SAOUT_SA_T, sasp, (void *)sap) ||
|
||||
(*sae->sae_sacopyout)(SAOUT_SAP_T, &sap, (void *)sapp))) ||
|
||||
(sae->sae_sacopyout == NULL &&
|
||||
@ -1533,8 +1523,8 @@ sa_makeupcalls(struct lwp *l)
|
||||
/* Copying onto the stack didn't work. Die. */
|
||||
sadata_upcall_free(sau);
|
||||
#ifdef DIAGNOSTIC
|
||||
printf("sa_makeupcalls: couldn't copyout sa_t "
|
||||
"%d for %d.%d\n", i, p->p_pid, l->l_lid);
|
||||
printf("sa_makeupcalls(%d.%d): couldn't copyout\n",
|
||||
p->p_pid, l->l_lid);
|
||||
#endif
|
||||
if (e_ss != NULL) {
|
||||
kmem_free(e_ss, sizeof(*e_ss));
|
||||
|
Loading…
Reference in New Issue
Block a user