From owner-freebsd-fs@FreeBSD.ORG Mon Jun 26 03:43:50 2006 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 995B216AA29 for ; Mon, 26 Jun 2006 03:43:50 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 012FE450E9 for ; Mon, 26 Jun 2006 03:15:09 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [127.0.0.1] (pooker.samsco.org [168.103.85.57]) (authenticated bits=0) by pooker.samsco.org (8.13.4/8.13.4) with ESMTP id k5Q2rD5u008155; Sun, 25 Jun 2006 20:53:20 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <449F4C1A.1000704@samsco.org> Date: Sun, 25 Jun 2006 20:53:14 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20051230 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Pedro Martelletto References: <20060622153504.GB835@static.protection.cx> In-Reply-To: <20060622153504.GB835@static.protection.cx> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.1.1 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on pooker.samsco.org Cc: freebsd-fs@freebsd.org Subject: Re: plug memory leaks and fix nested loops in udf_find_partmaps() X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jun 2006 03:43:50 -0000 Thanks for this, I'll look at committing it right now. Scott Pedro Martelletto wrote: > currently, there are two nested 'for' loops in udf_find_partmaps() which > use the same control variable (i), as well as memory leaks in two error > paths, which the following diff should fix. > > -p. > > Index: udf_vfsops.c > =================================================================== > RCS file: /home/ncvs/src/sys/fs/udf/udf_vfsops.c,v > retrieving revision 1.41 > diff -u -p -r1.41 udf_vfsops.c > --- udf_vfsops.c 26 May 2006 01:21:51 -0000 1.41 > +++ udf_vfsops.c 22 Jun 2006 15:08:25 -0000 > @@ -728,7 +728,7 @@ udf_find_partmaps(struct udf_mnt *udfmp, > struct regid *pmap_id; > struct buf *bp; > unsigned char regid_id[UDF_REGID_ID_SIZE + 1]; > - int i, ptype, psize, error; > + int i, k, ptype, psize, error; > > for (i = 0; i < le32toh(lvd->n_pm); i++) { > pmap = (union udf_pmap *)&lvd->maps[i * UDF_PMAP_SIZE]; > @@ -776,6 +776,7 @@ udf_find_partmaps(struct udf_mnt *udfmp, > brelse(bp); > printf("Failed to read Sparing Table at sector %d\n", > le32toh(pms->st_loc[0])); > + FREE(udfmp->s_table, M_UDFMOUNT); > return (error); > } > bcopy(bp->b_data, udfmp->s_table, le32toh(pms->st_size)); > @@ -783,15 +784,16 @@ udf_find_partmaps(struct udf_mnt *udfmp, > > if (udf_checktag(&udfmp->s_table->tag, 0)) { > printf("Invalid sparing table found\n"); > + FREE(udfmp->s_table, M_UDFMOUNT); > return (EINVAL); > } > > /* See how many valid entries there are here. The list is > * supposed to be sorted. 0xfffffff0 and higher are not valid > */ > - for (i = 0; i < le16toh(udfmp->s_table->rt_l); i++) { > - udfmp->s_table_entries = i; > - if (le32toh(udfmp->s_table->entries[i].org) >= > + for (k = 0; k < le16toh(udfmp->s_table->rt_l); k++) { > + udfmp->s_table_entries = k; > + if (le32toh(udfmp->s_table->entries[k].org) >= > 0xfffffff0) > break; > } > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org"