From patchwork Tue Jul 22 02:07:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 372328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BB3AB1400FA for ; Tue, 22 Jul 2014 12:08:43 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9PUT-0007eU-39; Tue, 22 Jul 2014 02:07:41 +0000 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9PUR-00079f-7E for linux-mtd@lists.infradead.org; Tue, 22 Jul 2014 02:07:39 +0000 Received: by mail-pd0-f177.google.com with SMTP id p10so10217860pdj.36 for ; Mon, 21 Jul 2014 19:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=5PxYkkYPaguO1ZmNho8KJiiuJ49Rk2RJ4r0nLIacumE=; b=mYoXPuzFpmTZMEZTkzYJu6KyUr5xpXrFR2uBFRnFlR6VWYfjHdyJVXGgR6iDJCaIyT 2Iz9bbD6kWGfkPPBzHuQ0NNIhbIROg9uE+48C0priTxfP6YTn7oLOlL6NX5u77CeQC7F QPdy0nQSRqjZpaipPYLP+xzRwkKdGtm2H/LoC6/jb5L5Bq6FlLxkQK0LE+/mFMP/iBS3 lbxwd1IG+V5a0CVRKQMm+vMsIJ3VprNWodVRRRuhMoBT4Y7CMJK/CYwiQB3GGcfBB9Ig hqvEZwipOXJJUVCbNlp9a5icJhv9E52bYuRDsD8mKUJD3W6DIl7u9a3iku1RFkjtYYVC oTaw== X-Received: by 10.70.6.98 with SMTP id z2mr22670484pdz.83.1405994832341; Mon, 21 Jul 2014 19:07:12 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id rc3sm15551526pbc.5.2014.07.21.19.07.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jul 2014 19:07:11 -0700 (PDT) From: Brian Norris To: Subject: [PATCH] mtd: mtdswap: fix integer overflow Date: Mon, 21 Jul 2014 19:07:02 -0700 Message-Id: <1405994822-19376-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140721_190739_286084_7ED0D011 X-CRM114-Status: UNSURE ( 8.73 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c02:0:0:0:231 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Cc: Brian Norris X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Caught by Coverity. Signed-off-by: Brian Norris --- drivers/mtd/mtdswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 8b33b26eb12b..8ca8d41bb35e 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c @@ -1474,7 +1474,7 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) } eblocks = mtd_div_by_eb(use_size, mtd); - use_size = eblocks * mtd->erasesize; + use_size = (uint64_t)eblocks * mtd->erasesize; bad_blocks = mtdswap_badblocks(mtd, use_size); eavailable = eblocks - bad_blocks;