From patchwork Wed Nov 28 08:02:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huijin Park X-Patchwork-Id: 1004270 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fr2LMz8I"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="ihiEFXYB"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434Y7065nFz9ryk for ; Wed, 28 Nov 2018 19:03:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: Message-id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Owner; bh=68dpk6P7onK74gOX5af8x1gXEF+dpcYaAww4dTffTuw=; b=fr 2LMz8IDX5WD0UhzN6mw+lvNYX0vfRmBCvBL197LpAKe6Wwik6NABuwR5swRR/5OPDguFI0ulLTGZT 0MWBzZ3S9A1DUS7HTMC+gkHeUvWEFC5F8OuutN/ZB6easxha2DhSUpd/krSpls9oS65JTPnzQowQY Jee64NkqQ79CAwusZuzJp/LUjcm452T/G8T4xi9XOIXCLZmHaj31S21FzkF7tbJ/HPBYdBd7I15cc qcKjAd2uDuUSOWhj5EiD1qX6k+sdroWpViH7DrFrxS31R4xVOJb0Crryc4JtgVhSu+PMGKWSIhTRr 1pT+yd2Jzrrf4lKKJVirtm3rHPPX7BMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRuoK-0004UT-WD; Wed, 28 Nov 2018 08:03:05 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRuoH-0004Ti-9J for linux-mtd@lists.infradead.org; Wed, 28 Nov 2018 08:03:03 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181128080245euoutp027a3b6bbdf571a1c26c7197324aa81b62~rOv9qudh33067330673euoutp02J; Wed, 28 Nov 2018 08:02:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181128080245euoutp027a3b6bbdf571a1c26c7197324aa81b62~rOv9qudh33067330673euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1543392166; bh=EmIe6nFPKEzz80wkhOcNbeYCmFDnDnvZF9rKVNOCDAw=; h=From:To:Cc:Subject:Date:References:From; b=ihiEFXYBU6vhYWtpZnxiXRKvpZWuDNhStVU7UngOPbiuPqEPmlw92/OWxJ1q+P3HY DW5NDlxJou1sKuOJP+f3H0gP3lU/SSxqcgR0yQ+B8Ey+nfyy0kUnSAMI9D6/1fhvKL +so2Zq5xTfysPofmoXEDT83ES3W0D2KqyvLDWx8s= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181128080245eucas1p1cf827e90e36727fd21795aacfbedfeb5~rOv9LJ1uj1314313143eucas1p1N; Wed, 28 Nov 2018 08:02:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 13.2E.04441.5AB4EFB5; Wed, 28 Nov 2018 08:02:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181128080244eucas1p15d9478c4fdbb0609005a12d24703d6d8~rOv8MuYNy1318113181eucas1p1I; Wed, 28 Nov 2018 08:02:44 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-9a-5bfe4ba57996 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E2.8F.04128.4AB4EFB5; Wed, 28 Nov 2018 08:02:44 +0000 (GMT) Received: from localhost.localdomain ([10.88.99.240]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PIW00AW5908T130@eusync1.samsung.com>; Wed, 28 Nov 2018 08:02:44 +0000 (GMT) From: Huijin Park To: Boris Brezillon Subject: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows Date: Wed, 28 Nov 2018 03:02:14 -0500 Message-id: <1543392134-1443-1-git-send-email-huijin.park@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRmVeSWpSXmKPExsWy7djP87pLvf9FG8xeymnxcu8hZot9p/pZ LJ7d2stk0XHRxeLyrjlsFrublrFbHN1zj9mB3WPemmqPnbPusnscOtzB6LF5Sb1H35ZVjB6f N8kFsEVx2aSk5mSWpRbp2yVwZSzomc9W8JWj4lPfCcYGxi3sXYycHBICJhI9bUsYuxi5OIQE VjBKrGxdxQ7h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KYmVValF+fFFpTmrxIUZpDhYlcd7zBpVRQgLpiSWp2ampBalFMFkmDk6pBsYY4QkcfbcY +02s629eNVpkt/Y/P2vs3fZK5t7zCVbX19/p/MsvVePnbhT+TlT3ZP3jEwJBT3eIG2ptyl3/ KNos8QO/nV2qc/fzvTznZbbL/kwsmBHU/PlNqPGTzyvND3Rc6ErKX6V8pPPnNO8F53h8z+/1 sW3c0hW79NHu+fKeT7glwoS4jZVYijMSDbWYi4oTAU1asggFAgAA X-CMS-MailID: 20181128080244eucas1p15d9478c4fdbb0609005a12d24703d6d8 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181128080244eucas1p15d9478c4fdbb0609005a12d24703d6d8 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_000301_463574_61B525AA X-CRM114-Status: GOOD ( 14.46 ) X-Spam-Score: -6.7 (------) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-6.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 -1.5 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Marek Vasut , Geert Uytterhoeven , linux-mtd@lists.infradead.org, bbanghj.park@gmail.com, Huijin Park MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "huijin.park" The "params->size" is defined as "u64". And "info->sector_size" and "info->n_sectors" are defined as unsigned int and u16. Thus, u64 data might have strange data(loss data) if the result overflows an unsigned int. This patch casts "info->sector_size" to an u64. Signed-off-by: huijin.park Reviewed-by: Geert Uytterhoeven --- Changes since v1: * Made commit subject and message more clear. Changes since v2: * Adding the cast to only the first operand. --- drivers/mtd/spi-nor/spi-nor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index d9c368c..59a1075 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2459,7 +2459,7 @@ static int spi_nor_init_params(struct spi_nor *nor, memset(params, 0, sizeof(*params)); /* Set SPI NOR sizes. */ - params->size = info->sector_size * info->n_sectors; + params->size = (u64)info->sector_size * info->n_sectors; params->page_size = info->page_size; /* (Fast) Read settings. */