Subject: Re: memory leak in bpf_write
To: None <tech-net@NetBSD.org>
From: Peter Postma <peter@pointless.nl>
List: tech-net
Date: 06/20/2005 12:20:17
I'll commit this patch tomorrow if no-one objects.

On Fri, Jun 17, 2005 at 02:35:28PM +0200, Peter Postma wrote:
> As pointed out in PR/29138, bpf_write leaks memory in the EMSGSIZE case.
> Is it ok to commit the following patch?
> 
> Index: bpf.c
> ===================================================================
> RCS file: /cvsroot/src/sys/net/bpf.c,v
> retrieving revision 1.107
> diff -u -r1.107 bpf.c
> --- bpf.c	26 Feb 2005 22:45:09 -0000	1.107
> +++ bpf.c	17 Jun 2005 12:26:38 -0000
> @@ -589,8 +589,10 @@
>  	if (error)
>  		return (error);
>  
> -	if (m->m_pkthdr.len > ifp->if_mtu)
> +	if (m->m_pkthdr.len > ifp->if_mtu) {
> +		m_freem(m);
>  		return (EMSGSIZE);
> +	}
>  
>  	if (d->bd_hdrcmplt)
>  		dst.ss_family = pseudo_AF_HDRCMPLT;
> 

-- 
Peter Postma