From owner-freebsd-current@FreeBSD.ORG Sat Apr 17 10:14:44 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D745106566B; Sat, 17 Apr 2010 10:14:44 +0000 (UTC) (envelope-from gary.jennejohn@freenet.de) Received: from mout2.freenet.de (mout2.freenet.de [IPv6:2001:748:100:40::2:4]) by mx1.freebsd.org (Postfix) with ESMTP id 14DC58FC14; Sat, 17 Apr 2010 10:14:44 +0000 (UTC) Received: from [195.4.92.20] (helo=10.mx.freenet.de) by mout2.freenet.de with esmtpa (ID gary.jennejohn@freenet.de) (port 25) (Exim 4.72 #3) id 1O352w-0006OG-QN; Sat, 17 Apr 2010 12:14:42 +0200 Received: from p57ae2173.dip0.t-ipconnect.de ([87.174.33.115]:61185 helo=ernst.jennejohn.org) by 10.mx.freenet.de with esmtpa (ID gary.jennejohn@freenet.de) (port 25) (Exim 4.72 #3) id 1O352w-0002tq-Dl; Sat, 17 Apr 2010 12:14:42 +0200 Date: Sat, 17 Apr 2010 12:14:41 +0200 From: Gary Jennejohn To: Alfred Perlstein Message-ID: <20100417121441.7de4873b@ernst.jennejohn.org> In-Reply-To: <20100417011614.GR54028@elvis.mu.org> References: <20100417011614.GR54028@elvis.mu.org> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.7; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: current@freebsd.org Subject: Re: fix for compressed coredumps, please review X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gary.jennejohn@freenet.de List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Apr 2010 10:14:44 -0000 On Fri, 16 Apr 2010 18:16:14 -0700 Alfred Perlstein wrote: > Can I get a review for this? > > summary: > If doing compressed cores and there is an error, we leak > resources unless this is fixed. > > > Index: imgact_elf.c > =================================================================== > --- imgact_elf.c (revision 206498) > +++ imgact_elf.c (working copy) > @@ -29,7 +29,7 @@ > */ > > #include > -__FBSDID("$FreeBSD$"); > +__FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 205643 2010-03-25 14:31:26Z nwhitehorn $"); > > #include "opt_compat.h" > #include "opt_core.h" > @@ -1088,8 +1088,10 @@ > hdrsize = 0; > __elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count); > > - if (hdrsize + seginfo.size >= limit) > - return (EFAULT); > + if (hdrsize + seginfo.size >= limit) { > + error = EFAULT; > + goto done; > + } > > /* > * Allocate memory for building the header, fill it up, > @@ -1097,7 +1099,8 @@ > */ > hdr = malloc(hdrsize, M_TEMP, M_WAITOK); > if (hdr == NULL) { > - return (EINVAL); > + error = EINVAL; > + goto done; > } > error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize, > gzfile); > @@ -1125,8 +1128,8 @@ > curproc->p_comm, error); > } > > +done: > #ifdef COMPRESS_USER_CORES > -done: > if (core_buf) > free(core_buf, M_TEMP); > if (gzfile) > Looks good to me. Actually, you don't need the "if (core_buf)" since free(9) DTRT with NULL. -- Gary Jennejohn (gj@)