From patchwork Wed May 4 11:26:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john.maxin@nokia.com X-Patchwork-Id: 94001 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 ozlabs.org (Postfix) with ESMTPS id 9B084B6F5C for ; Wed, 4 May 2011 21:28:31 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QHaEg-00005z-K4; Wed, 04 May 2011 11:27:18 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1QHaEe-0001ja-Ll; Wed, 04 May 2011 11:27:16 +0000 Received: from smtp.nokia.com ([147.243.128.26] helo=mgw-da02.nokia.com) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QHaEc-0001j8-35 for linux-mtd@lists.infradead.org; Wed, 04 May 2011 11:27:15 +0000 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-da02.nokia.com (Switch-3.4.4/Switch-3.4.3) with ESMTP id p44BQcif006461; Wed, 4 May 2011 14:27:03 +0300 Received: from smtp.mgd.nokia.com ([65.54.30.5]) by vaebh106.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 4 May 2011 14:26:50 +0300 Received: from 008-AM1MMR1-002.mgdnok.nokia.com (65.54.30.57) by NOK-am1MHUB-01.mgdnok.nokia.com (65.54.30.5) with Microsoft SMTP Server (TLS) id 8.2.255.0; Wed, 4 May 2011 13:26:49 +0200 Received: from 008-AM1MPN1-021.mgdnok.nokia.com ([169.254.1.188]) by 008-AM1MMR1-002.mgdnok.nokia.com ([65.54.30.57]) with mapi id 14.01.0289.008; Wed, 4 May 2011 13:26:49 +0200 From: To: Subject: [PATCH] add a check to prevent the incrementing of possible NULL value for "region" in onenand_base.c Thread-Topic: [PATCH] add a check to prevent the incrementing of possible NULL value for "region" in onenand_base.c Thread-Index: AQHMCk4o1QX9weCCN0CIlzCznknZIQ== Date: Wed, 4 May 2011 11:26:48 +0000 Message-ID: <77DFD0EF40BC5042BB7221A1EFFF75709578@008-AM1MPN1-021.mgdnok.nokia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.99.11] MIME-Version: 1.0 X-OriginalArrivalTime: 04 May 2011 11:26:50.0093 (UTC) FILETIME=[292529D0:01CC0A4E] X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110504_072714_329596_B8617A47 X-CRM114-Status: GOOD ( 10.27 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [147.243.128.26 listed in list.dnswl.org] Cc: kyungmin.park@samsung.com, dwmw2@infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 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 Hi, Coverity has reported that inside the function "onenand_block_by_block_erase()" in onenand_base.c, we should add checks to prevent the incrementing of possible NULL value for "region" Thanks a lot to Adrian Hunter for suggesting a better solution. Signed-off-by: Maxin B. John diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 56a8b20..fd659f8 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -2424,7 +2424,7 @@ static int onenand_block_by_block_erase(struct mtd_info *mtd, len -= block_size; addr += block_size; - if (addr == region_end) { + if (region && addr == region_end) { if (!len) break; region++;