From patchwork Thu May 14 08:28:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Park X-Patchwork-Id: 27202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 bilbo.ozlabs.org (Postfix) with ESMTPS id F3158B7080 for ; Thu, 14 May 2009 18:30:24 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1M4WJC-0004tk-FM; Thu, 14 May 2009 08:28:54 +0000 Received: from mail-gx0-f158.google.com ([209.85.217.158]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1M4WJ2-0004sQ-Li for linux-mtd@lists.infradead.org; Thu, 14 May 2009 08:28:51 +0000 Received: by gxk2 with SMTP id 2so2224091gxk.3 for ; Thu, 14 May 2009 01:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=p+MOrR/BGItd6hQi9JPssgYwvyzNjGQakk+vqEJHHSM=; b=t0Oa7Q0kzYDcyW32A+oZgINJSQG99w8Rj58oeyfj9LMzNx6pcFMnscSF8l0X+Cf8Fw FxXIYFFnsFNg+Yz2wE3EH8frSN57EOuD4y5aNiWHsEyZEw3vtyx8bfigKuk5W1wIyE9r PVXp98X6Q0Yj4PreHohyuSX0Z8aoYoLJF9rfQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; b=FhJskV1aoq7f80eNW2xUi8Uq1O20YJm8s+0SyIT9hY+yaVJvYeIcwgvrsI/Smpjruo S0Vn0Pic+ZI1kf85Zsz3d77zagGcTGrMdy0Di1P1Foz3c0MEfyS+KLRYssKTSwp2S2vj bbXQ++ncHowPbFQH34QCre2Skji4M9aiqxk5c= MIME-Version: 1.0 Received: by 10.151.8.15 with SMTP id l15mr3027547ybi.293.1242289723012; Thu, 14 May 2009 01:28:43 -0700 (PDT) Date: Thu, 14 May 2009 17:28:42 +0900 X-Google-Sender-Auth: c0eb0907d674d727 Message-ID: <280b69ac0905140128u135f8b2aua50114faebb593e0@mail.gmail.com> Subject: oobavail size calculation error in nand_base.c From: Jinyoung Park To: tglx@linutronix.de X-Spam-Score: 0.0 (/) Cc: linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 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 Hello. I found error in nand_base.c. In nand_scan_tail() function, oobavail size calculation result is wrong as follow circumstances. - Define nand_ecclayout using full oobfree array like below. .oobfree = { {2, 6}, {11, 2}, {16, 8}, {27, 2}, {32, 8}, {43, 2},{48, 8}, {59, 2} } - Using ARM EABI cross compiler when kernel compile also enable "Use the ARM EABI to compile the kernl" feature in kernel menuconfig. I using ARM EABI compiler that codesourcery release arm-2008q3-51. In this case, right oobavail size is 38 but result is too much value(e.g. 2703572308...). It's random. I think sometimes happen that after beyond oobfree array(oobfree[8]) is not 0 when ARM EABI compilation. Below codes are my modified code. Please check... Thanks. Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 3d7ed43..abb5998 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2756,9 +2756,12 @@ int nand_scan_tail(struct mtd_info *mtd) * the out of band area */ chip->ecc.layout->oobavail = 0; - for (i = 0; chip->ecc.layout->oobfree[i].length; i++) + for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) { + if (chip->ecc.layout->oobfree[i].length == 0) + break; chip->ecc.layout->oobavail += chip->ecc.layout->oobfree[i].length; + } mtd->oobavail = chip->ecc.layout->oobavail; ______________________________________________________