From patchwork Wed Dec 16 00:37:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 41227 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 2B156B6F10 for ; Wed, 16 Dec 2009 11:37:57 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NKhrc-0003bV-BC; Wed, 16 Dec 2009 00:35:36 +0000 Received: from mail-ew0-f221.google.com ([209.85.219.221]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NKhrV-0003av-61 for linux-mtd@lists.infradead.org; Wed, 16 Dec 2009 00:35:33 +0000 Received: by ewy21 with SMTP id 21so538992ewy.2 for ; Tue, 15 Dec 2009 16:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=Z+9/2MGu8WmNLoAlXGtIkDC1ycOFyHXWKfUkXDfVAbY=; b=M54l6gl0z5MKk3HspfGhwDx+OyPyv3sByaUdnBtgcCtwyol5vj7pGYoFzel7MHzdLI ZFlOKEEfKSblICR/8QMcBEfWSujeKf66tlF44BZRDdByLhrkss+AGrJ/fAOhLjB0tH/W 6FxgayHSjLu7RtQF0fewH1bKH4Nka+UCrDrVM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=uojwo5MvlMms6IkYRf02yFjXZa+7EIIMYfDvq8BVn55SVrzUwCwDVwAfD3eOJJuAk/ +cpoqZuQdvXyknQwgCIWnz9kVXXy8Z51hbm1Rj3BjLg28ACAUA45u49y8rmBWnICo3wV Xocz7BvJD0poIgn1Z45cYGJSxsTlWPAaxbSGM= Received: by 10.213.23.195 with SMTP id s3mr5911118ebb.5.1260923726578; Tue, 15 Dec 2009 16:35:26 -0800 (PST) Received: from zoinx.mars (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id 10sm786812eyd.13.2009.12.15.16.35.25 (version=SSLv3 cipher=RC4-MD5); Tue, 15 Dec 2009 16:35:26 -0800 (PST) Message-ID: <4B282BBD.4050106@gmail.com> Date: Wed, 16 Dec 2009 01:37:17 +0100 From: Roel Kluin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-3.9.b4.fc12 Thunderbird/3.0b4 MIME-Version: 1.0 To: Kyungmin Park , linux-mtd@lists.infradead.org, Andrew Morton , LKML Subject: [PATCH] OneNAND: Fix test of unsigned in onenand_otp_walk() X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091215_193529_361370_27484069 X-CRM114-Status: GOOD ( 14.60 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ 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 mtd->writesize and len are unsigned so the test does not work. Signed-off-by: Roel Kluin Acked-by: Kyungmin Park --- you can test this with: #include int main() { int c = 1, d = 1; unsigned a = 30; unsigned b = 10; if ((b * c) - (d + a) < 0) printf("good\n"); else printf("bad\n"); return 0; } diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index ff66e43..cbe2711 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -2725,7 +2725,7 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, } /* Check User/Factory boundary */ - if (((mtd->writesize * otp_pages) - (from + len)) < 0) + if (mtd->writesize * otp_pages < from + len) return 0; onenand_get_device(mtd, FL_OTPING);