From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754341AbbI2A27 (ORCPT ); Mon, 28 Sep 2015 20:28:59 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34121 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbbI2A25 (ORCPT ); Mon, 28 Sep 2015 20:28:57 -0400 Date: Mon, 28 Sep 2015 17:28:55 -0700 From: Brian Norris To: Peng Fan Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, David Woodhouse Subject: Re: [PATCH v2] mtd: blktrans: fix multiplication overflow Message-ID: <20150929002855.GR31505@google.com> References: <1441978907-19520-1-git-send-email-van.freenix@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441978907-19520-1-git-send-email-van.freenix@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2015 at 09:41:47PM +0800, Peng Fan wrote: > In drivers/mtd/mtd_blkdevs.c: > 406 set_capacity(gd, (new->size * tr->blksize) >> 9); > The type of new->size is unsigned long and the type of tr->blksize is int, > the result of 'new->size * tr->blksize' may exceed ULONG_MAX on 32bit > machines. > > I use nand chip MT29F32G08CBADBWP which is 4GB and the parameters passed > to kernel is 'mtdparts=gpmi-nand:-(user)', the whole nand chip will be > treated as a 4GB mtd partition. new->size is 0x800000 and tr->blksize is > 0x200, 'new->size * tr->blksize' however is 0. This is what we do not want > to see. > > Using type cast u64 to fix the multiplication overflow issue. > > Signed-off-by: Peng Fan > Cc: David Woodhouse > Cc: Brian Norris > --- > > Changes V2: > use type cast to avoid build break for platforms which does not support 64 bit multilplication. Thanks, pushed to l2-mtd.git