From dbbe2b1dd791f1bfeb676e7836f7eb5ce28a75ce Mon Sep 17 00:00:00 2001 From: simonb Date: Thu, 1 Jun 2000 13:36:51 +0000 Subject: [PATCH] Plug a slow kernel memory leak - a page was lost for each system or zombie process queried with the KERN_PROC_ARGS sysctl. Fixed by moving a malloc call after all possible early return conditions. --- sys/kern/kern_sysctl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 3ab42e02c3cc..2fb531011934 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sysctl.c,v 1.66 2000/05/31 05:02:34 thorpej Exp $ */ +/* $NetBSD: kern_sysctl.c,v 1.67 2000/06/01 13:36:51 simonb Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -1374,10 +1374,6 @@ sysctl_procargs(name, namelen, where, sizep, up) } if (where == NULL || sizep == NULL) return (EINVAL); - /* - * Allocate a temporary buffer to hold the arguments. - */ - arg = malloc(PAGE_SIZE, M_TEMP, M_WAITOK); /* * Zombies don't have a stack, so we can't read their psstrings. @@ -1395,6 +1391,11 @@ sysctl_procargs(name, namelen, where, sizep, up) PHOLD(p); p->p_vmspace->vm_refcnt++; /* XXX */ + /* + * Allocate a temporary buffer to hold the arguments. + */ + arg = malloc(PAGE_SIZE, M_TEMP, M_WAITOK); + /* * Read in the ps_strings structure. */