From patchwork Mon Nov 3 08:41:58 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 6889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8A13ADDDEE for ; Mon, 3 Nov 2008 19:38:01 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1Kwuu7-0003a9-1b; Mon, 03 Nov 2008 08:35:19 +0000 Received: from smtp.nokia.com ([192.100.122.230] helo=mgw-mx03.nokia.com) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1Kwuu2-0003a1-Fd for linux-mtd@lists.infradead.org; Mon, 03 Nov 2008 08:35:14 +0000 Received: from esebh107.NOE.Nokia.com (esebh107.ntc.nokia.com [172.21.143.143]) by mgw-mx03.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id mA38YvHb029205; Mon, 3 Nov 2008 10:35:10 +0200 Received: from vaebh102.NOE.Nokia.com ([10.160.244.23]) by esebh107.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 3 Nov 2008 10:34:23 +0200 Received: from vaebe112.NOE.Nokia.com ([10.160.244.81]) by vaebh102.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 3 Nov 2008 10:34:23 +0200 Received: from [172.21.40.95] ([172.21.40.95]) by vaebe112.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 3 Nov 2008 10:34:22 +0200 Message-ID: <490EB956.5050700@nokia.com> Date: Mon, 03 Nov 2008 10:41:58 +0200 From: Adrian Hunter User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: "J. Scott Merritt" Subject: Re: ubinize corrections References: <20081102142315.453628de.merrij3@rpi.edu> In-Reply-To: <20081102142315.453628de.merrij3@rpi.edu> X-OriginalArrivalTime: 03 Nov 2008 08:34:22.0554 (UTC) FILETIME=[F8CC03A0:01C93D8E] X-Nokia-AV: Clean X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.100.122.230 listed in list.dnswl.org] Cc: linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org J. Scott Merritt wrote: > Dear list, > > I believe that I have stumbled upon two problems with the latest version > of ubinize.c in mtd-utils - one serious, and one not so serious. > > - First, the easy one: At line 457, I believe that we should be printing > args.subpage_size rather than ui.min_io_size. > > - More seriously, I believe that the "flags" field in the ubigen_vol_info > structures is not being properly initialized. Line 494 allocates memory > for these structures with malloc, so they are not cleared to zero. The > read_section function updates the flag field if the AUTO-RESIZE flag is > specified, but does not otherwise initialize or clear it. > > I reckon the latter problem could be repaired either with calloc, or by > modifying read_section to more directly set/clear the flag. > > Thanks, Scott. I agree. Here's the patch: From: Adrian Hunter Date: Mon, 3 Nov 2008 10:36:32 +0200 Subject: [PATCH] ubinize: correct subpage_size print and initialise vol_info to zero Reported-by: "J. Scott Merritt" Signed-off-by: Adrian Hunter --- ubi-utils/new-utils/src/ubinize.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ubi-utils/new-utils/src/ubinize.c b/ubi-utils/new-utils/src/ubinize.c index ebd5aa0..4f3e8a1 100644 --- a/ubi-utils/new-utils/src/ubinize.c +++ b/ubi-utils/new-utils/src/ubinize.c @@ -454,7 +454,7 @@ int main(int argc, char * const argv[]) verbose(args.verbose, "LEB size: %d", ui.leb_size); verbose(args.verbose, "PEB size: %d", ui.peb_size); verbose(args.verbose, "min. I/O size: %d", ui.min_io_size); - verbose(args.verbose, "sub-page size: %d", ui.min_io_size); + verbose(args.verbose, "sub-page size: %d", args.subpage_size); verbose(args.verbose, "VID offset: %d", ui.vid_hdr_offs); verbose(args.verbose, "data offset: %d", ui.data_offs); @@ -491,7 +491,7 @@ int main(int argc, char * const argv[]) goto out_dict; } - vi = malloc(sizeof(struct ubigen_vol_info) * sects); + vi = calloc(sizeof(struct ubigen_vol_info), sects); if (!vi) { errmsg("cannot allocate memory"); goto out_dict;