Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp850233imu; Wed, 28 Nov 2018 00:05:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uacp0fG0i6IWvTzS/3XXDw7spHw5OXrJMj5BsY0IUJmoUNulTtLk9Jfv1HCrfMVLKDQ8Lj X-Received: by 2002:a17:902:4025:: with SMTP id b34mr36211906pld.181.1543392328008; Wed, 28 Nov 2018 00:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543392327; cv=none; d=google.com; s=arc-20160816; b=rumrRkBiQ9OVlF7nNHdq0oNS/16R3e6xINWlZqi+77NwG/hmhVIMMs2eiDq0nYjd2A xrb0k4E40AE73lZ6fPp++3yaE95jN0kuH2bnk9Hp6WIRjmVl1Z2hG5UVmNqsX331eXjU PWdqad/rinHSLjYhqhdxnTDak1eEPVXfQvbPlh3LBF0vEUaN8KHN/cM2JoECUbwkH/ru t2vWaGHAWiy12axAnuPNFisqHdwwxRxbhe0YRcZzbZx8gF7jt3M4yu79YSanSrhfDkCF +IcUEV+c3QYo/sP4Wkse8K5NJb6C3O8C5c73Kb54XU1PleMJa2HtX3o9oFDJWtw07lcu qcpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=EmIe6nFPKEzz80wkhOcNbeYCmFDnDnvZF9rKVNOCDAw=; b=X/XAyHQJ+CHeGGe6f8P0zvV34zOR8IQ2jzFYFnZ1HBl+WdevwxH2OAT23CsK6Hr45j W3WCfqcm2DeBJfnI+QFwr1/GbaZxQkMcs7xt0VzU1qcasmo5LiNQt+Ndbs6946DkqSIn T6iQbnqQCkMsnpH+mURft5F7EfoPVZzO2D9g8tPjmVkjvlYAL6+Pm+drsrKYtNBv2uxx gqvBcUE1eFZEJdqpb7r8Zv2tWt+oGsYcY2iQrct4oMvTZKMKKVVcun41mKgcYYq16E9P HB/cWig9sVGPi8W0d+HRGKKzumS/Wkff4TGIiDd2/9hQtZmSY9BfvogQjL0jpqM+8UnY FkOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ihiEFXYB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4-v6si7025498plb.258.2018.11.28.00.05.12; Wed, 28 Nov 2018 00:05:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ihiEFXYB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727775AbeK1TDc (ORCPT + 99 others); Wed, 28 Nov 2018 14:03:32 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:33578 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbeK1TDc (ORCPT ); Wed, 28 Nov 2018 14:03:32 -0500 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 Cc: Marek Vasut , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Huijin Park , bbanghj.park@gmail.com, Geert Uytterhoeven 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 VjBKrGxdxQ7hfGaUeHFuGhNM1dZ769ggEssYJe5cf8UM4fxllFi0cAEbSBWbgLbE9bVbGUFs EQFDiZVTW1hAipgFLjFKXH/6FqxIWMBVYsXMLrCxLAKqEptmtrOA2LwCbhK7Nq+CWicncfNc J9gGCYG3rBK7J/9ihki4SPS+fg9VJCzx6jjMFzISlyd3s0DY2RK/HrUC2RxAdoXE23kqEGFj iXdv14KNYRbgk5i0bTozRAmvREebEESJh8TD24/B7hcSiJXofHyQcQKjxAJGhlWM4qmlxbnp qcWGeanlesWJucWleel6yfm5mxiBsXb63/FPOxi/Xko6xCjAwajEwxuQ+jdaiDWxrLgy9xCj BAezkghvqd2/aCHelMTKqtSi/Pii0pzU4kOM0hwsSuK81QwPooUE0hNLUrNTUwtSi2CyTByc Ug2MG7wjawU/C/gu/eHILyiZ8t5vbs0ThdeXnzopKlUuTmH8wJMy4/lKnafLzhu9f2+TbbUr U85GxEG31X5qUMZ9xncad9wv2a5amOsQt7b5m4TNTNVJd+ecMdHMs1ir43Ljc49u346VuqmG u20Opa/vvRtl88ru7YwvVQd3LOXrXmhnyPFVe1m+EktxRqKhFnNRcSIAJ2Qlg7ECAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEJMWRmVeSWpSXmKPExsVy+t/xy7pLvP9FG/y+xG7xcu8hZot9p/pZ LJ7d2stk0XHRxeLyrjlsFrublrFbHN1zj9mB3WPemmqPnbPusnscOtzB6LF5Sb1H35ZVjB6f N8kFsEVx2aSk5mSWpRbp2yVwZSzomc9W8JWj4lPfCcYGxi3sXYycHBICJhJb761j62Lk4hAS WMIo0ff9LjuE859RovHANlaQKjYBbYnra7cygtgiAoYSK6e2sIAUMQtcYpT49eQt2ChhAVeJ FTO7mEBsFgFViU0z21lAbF4BN4ldm1cxQayTk7h5rpN5AiPXAkaGVYwiqaXFuem5xUZ6xYm5 xaV56XrJ+bmbGIEhse3Yzy07GLveBR9iFOBgVOLhDUj9Gy3EmlhWXJl7iFGCg1lJhLfU7l+0 EG9KYmVValF+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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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. */ -- 1.7.9.5