From patchwork Wed Apr 22 02:51:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brownell X-Patchwork-Id: 26289 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 E924FB6F35 for ; Wed, 22 Apr 2009 13:07:32 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LwSl9-0004Oa-A0; Wed, 22 Apr 2009 03:04:27 +0000 Received: from n13a.bullet.mail.mud.yahoo.com ([68.142.207.51]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1LwSl0-0004O9-3x for linux-mtd@lists.infradead.org; Wed, 22 Apr 2009 03:04:24 +0000 Received: from [68.142.200.227] by n13.bullet.mail.mud.yahoo.com with NNFMP; 22 Apr 2009 03:04:16 -0000 Received: from [68.142.201.253] by t8.bullet.mud.yahoo.com with NNFMP; 22 Apr 2009 03:04:16 -0000 Received: from [127.0.0.1] by omp414.mail.mud.yahoo.com with NNFMP; 22 Apr 2009 03:04:16 -0000 X-Yahoo-Newman-Id: 713883.37040.bm@omp414.mail.mud.yahoo.com Received: (qmail 51500 invoked from network); 22 Apr 2009 03:04:16 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:To:Subject:Cc:Content-Disposition:From:Date:MIME-Version:Message-Id:Content-Type:Content-Transfer-Encoding; b=SDtFKJXjhPTL9X12rLBTm2qTGsLlcwYLU0sk21Xr3BDlTU0O/0DnF1yTCvbaNBCsUYvqWxrj41/5c8Mn4GFRk/zilcxnlX8/JvP4Ca5E8nkMIKPr7L6Em4Ej1CZ2CoXGy2DIg20jSxH9uT8kcRus7veozgkuU6L2SG7Q2vgAD2M= ; Received: from unknown (HELO albert) (david-b@69.226.223.132 with plain) by smtp103.sbc.mail.sp1.yahoo.com with SMTP; 22 Apr 2009 03:04:15 -0000 X-YMail-OSG: xV6oiLsVM1lgiqg6xME2whneM0KDDcZytMBmAc5W_SZE8PuvmCq8s.r3bpqufg1Uc3u8ZpWGAau5gdbK1R5UP36lUcLSA0Q.cCrNdofcQvL438H3P5wE7g5DeefRpJJHQi_IuMvsUd2ZyiRo8nkGvRt5Nmg9KfK8x9VtZLZPB5IFjF2V49nFlHjv5EUPO.f.e4lublxJAb3Zp5VAnucNW4v8piWEpyd6ZycwmtTKYPj0NXVe8ofILzZjBHD2yI4blTqGzmGC0UPvtUKTE.g8lRy4egqJ19BaugRpFpywD5YwLS6BKACxlx4IBA-- X-Yahoo-Newman-Property: ymail-3 To: Linux MTD Subject: [patch/RESEND 2.6.30-rc2 1/3] NAND: don't walk past end of oobfree[] Content-Disposition: inline From: David Brownell Date: Tue, 21 Apr 2009 19:51:20 -0700 MIME-Version: 1.0 Message-Id: <200904211951.21270.david-b@pacbell.net> X-Spam-Score: 0.0 (/) Cc: dwmw2@infradead.org, Thomas Gleixner , "Narnakaje, Snehaprabha" , Andrew Morton 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 From: David Brownell Resolve issue noted by Sneha: when computing oobavail from the list of free areas in the OOB, don't assume there will always be an unused slot at the end. With ECC_HW_SYNDROME and 4KB page chips, it's fairly likely there *won't* be one. Signed-off-by: David Brownell Cc: "Narnakaje, Snehaprabha" " --- RESEND refreshed 7-april version. Still seems appropriate for a 2.6.30-rc merge. drivers/mtd/nand/nand_base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2756,7 +2756,8 @@ 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; chip->ecc.layout->oobfree[i].length + && i < ARRAY_SIZE(chip->ecc.layout->oobfree); i++) chip->ecc.layout->oobavail += chip->ecc.layout->oobfree[i].length; mtd->oobavail = chip->ecc.layout->oobavail;