Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4261082imu; Mon, 12 Nov 2018 08:13:46 -0800 (PST) X-Google-Smtp-Source: AJdET5e3qBdL+v0KpXURovFmQvOWPWLfA2yEMi6eUcqxeu9G0JPX3dPUqfB9Rf2EQggzq3CuGaVL X-Received: by 2002:a63:594d:: with SMTP id j13mr1343076pgm.210.1542039226356; Mon, 12 Nov 2018 08:13:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542039226; cv=none; d=google.com; s=arc-20160816; b=HuEb89nvsg6FPantP6j2ywitzcvZv3LpKuNyWVXHaBqKCJNF81VpSLK1/4vEZjNPyN KvYUONoCMXCXT67Od3YMNTxhH5MllkYf0f+qRYjkRUC9XhzG9mu+IBP2cAWOa4Qy4bZv JG1Xa2qC0hp3IxhjVp/yO+HzBb1xHZUXcN4BbHiwlYRnGPUnWzAH7/e7QjnZOBNl5GMN ThTaXRA84S3MyBMgwo9ODxBN7Xwg8Qm1zK+SxU/B+saxUEga/G9mdEN1htazuBXvMwGn E3TPpJMtvSMckW4n1L1lxDH8Fwwnemj5rFWK2cAYsbPXD0P8rtcmf2ZziFyT5EXb0oaq 2iow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mRGD8zhWkHchDC7PtnDjUMIqDk/KRXDdmAqSruj1iLw=; b=LLnmkEki6P489se47y/uEkp0/gIUAretY3FdDT6XyFts00mKeF7z6ODGoJ6DEXQBDF D5pKSa4ZIFxbTJaRRo/OajcgWEpDKCuCpvbmsWgURo50O/jbSfLtA0SsZrKjqMgbaWwn WjeFAw12JCwyvR5dB5e+ZPjaapUrpdkUmfY3E+iEvvvjgDCrRkp1Vrb7TTBaeNkYNMPm GVwJjIfj+uzNA+39+OYDTBgQi6pO/x9OrsjPjcUV42JB61fow/07TBxlDI934a0ouAan kO+jR65hzxEed9JR4WvYyQt4FJrIFhryzVX8DhcjPcLJGg8xjT3KRJ7EPBcdF3/5TJYB dAig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d9QMNLq3; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l194si17416647pga.594.2018.11.12.08.13.30; Mon, 12 Nov 2018 08:13:46 -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=@gmail.com header.s=20161025 header.b=d9QMNLq3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729914AbeKMCG4 (ORCPT + 99 others); Mon, 12 Nov 2018 21:06:56 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36539 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbeKMCG4 (ORCPT ); Mon, 12 Nov 2018 21:06:56 -0500 Received: by mail-lf1-f67.google.com with SMTP id h192so6586515lfg.3 for ; Mon, 12 Nov 2018 08:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mRGD8zhWkHchDC7PtnDjUMIqDk/KRXDdmAqSruj1iLw=; b=d9QMNLq3cmEL9CJrN/2CUAK05loDMefJA0Ng4yQG1UH+KlJukkbQBoyeFna1nAvMmG Pcl54xW7DyKCO0+RRBeZ0mk2cxLhljXRmd7C9w1fSuks9Iu68WhCU5Yb0BYFaBormdzD QP3eGQ+tbnMk62sQcvb3CxJFpxK35pdK92XeS4p1vBhloXShbP9rxU2rbHxLtup8V9/Z TJhzf5kCBgOt6B0u0xoyyqp9g7DiLSM339ybognmK22cUod17Y2whA45B0E9RN87S+xD 2vitrbUvqon7+7MGEc0oyKtAs8iTzkWym0k3APmBLYzJZAAWVitUxLlwfKIoKkq3sl5R NuSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mRGD8zhWkHchDC7PtnDjUMIqDk/KRXDdmAqSruj1iLw=; b=RmVIzdhVZcyO/V7D4Ps5vH3a986Yhp29UPycMzLG51htxa7YfNTj6ZU6c4pzVcNW/O 4XC7boTiwAmtel4DPEwG3uKKTftiDlzBMcCUc8mTiXfgb3WVrhgL3TG4b9RFKtlWamv0 u+wTo0JQlTomkJOn5edScwtgR4fRLAb6VHviqn1Kblu23jyYP3PR34x4KsUlYJZZRpu5 BTia2jGyutAZTPy94GnGPDZyuJTr2f7aRDZ/50GrW90IyD5JiUPtVdbALjHh1zPm7NgZ pa2GePbUlRxSF9JC3AKzrfhQYjvRhPGUr903jaH6bGWq5+axAazLEgethWcv9rkBG+wG 5xdw== X-Gm-Message-State: AGRZ1gIYyDFikTavugUOAAwt3i60D4Bus7MoRKMZtN1XfOPqnkE3f64r cPk9iDGO58CPhxnPelp14JWWpbBXklvV7Nb61Uw= X-Received: by 2002:a19:ae03:: with SMTP id f3mr1048624lfc.86.1542039180489; Mon, 12 Nov 2018 08:13:00 -0800 (PST) MIME-Version: 1.0 References: <1535009282-1480-1-git-send-email-huijin.park@samsung.com> <20181031145505.6b034b84@bbrezillon> In-Reply-To: <20181031145505.6b034b84@bbrezillon> From: Huijin Park Date: Tue, 13 Nov 2018 01:12:48 +0900 Message-ID: Subject: Re: [PATCH] mtd: cast to u64 to avoid unexpected error To: boris.brezillon@bootlin.com Cc: huijin.park@samsung.com, marek.vasut@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris Thanks for review. I will send patch again. On Wed, Oct 31, 2018 at 10:55 PM Boris Brezillon wrote: > > Hi Huijin, > > Subject prefix should be "mtd: spi-nor: ...", and please replace > "unexpected error" by "unsigned int overflows". > > On Thu, 23 Aug 2018 03:28:02 -0400 > Huijin Park wrote: > > > From: "huijin.park" > > > > the params->size is defined as "u64" > > and, "info->sector_size" and "info->n_sectors" is defined as unsgined and u16 > > ^ are ^ unsigned > > > thus, u64 data might have strange data(loss data) if data is overflow. > > ^ if the result > overflows an unsigned int. > > > this patch cast it to u64. > > ^casts info->sector_size to an u64. > > > > > Signed-off-by: huijin.park > > --- > > 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..527f281 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 * (u64)info->n_sectors; > > ^ this cast is not needed. > > BTW, I doubt we'll ever have to deal with NORs that are more than 4GB, > but making static code analysis tools happy and enforcing code > correctness is important too. > I agree that enforcing code correctness is important as your said too. > > params->page_size = info->page_size; > > > > /* (Fast) Read settings. */ > > Regards, > > Boris Thanks & best regards, Huijin