Bug 25932

Summary: possible memory leak in /sys/kern/kern_proc.c
Product: Base System Reporter: davidx <davidx>
Component: kernAssignee: dwmalone
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description davidx 2001-03-20 00:40:01 UTC
a possible memory leak exists in /sys/kern/kern_proc.c, in function 
enterpgrp(), before returns ESRCH, it does not free pre-allocated pgrp,
hope I am not making a mistake.

Fix: a patch is available:
Comment 1 dwmalone 2001-03-23 20:10:34 UTC
On Mon, Mar 19, 2001 at 04:34:26PM -0800, davidx@viasoft.com.cn wrote:

> --- kern_proc.c.orig    Tue Mar 20 08:22:37 2001
> +++ kern_proc.c Tue Mar 20 08:22:57 2001
> @@ -157,10 +157,10 @@
>          */
>         KASSERT(p->p_pid == pgid,
>             ("enterpgrp: new pgrp and pid != pgid"));
> -       MALLOC(pgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP,
> -           M_WAITOK);
>         if ((np = pfind(savepid)) == NULL || np != p)
>             return (ESRCH);
> +       MALLOC(pgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP,
> +           M_WAITOK);
>         if (mksess) {
>             register struct session *sess;

A similar bug seems to be present in -current. I'll test your fix
and then commit it there.

	David.
Comment 2 dwmalone freebsd_committer freebsd_triage 2001-03-23 20:11:02 UTC
Responsible Changed
From-To: freebsd-bugs->dwmalone

I'll test the patch in -current and commit it all going well.
Comment 3 dwmalone freebsd_committer freebsd_triage 2001-05-01 16:01:14 UTC
State Changed
From-To: open->closed

Patch committed to -current and -stable. Thanks.