[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20150929002855.GR31505@google.com>
Date: Mon, 28 Sep 2015 17:28:55 -0700
From: Brian Norris <computersforpeace@...il.com>
To: Peng Fan <van.freenix@...il.com>
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH v2] mtd: blktrans: fix multiplication overflow
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 <van.freenix@...il.com>
> Cc: David Woodhouse <dwmw2@...radead.org>
> Cc: Brian Norris <computersforpeace@...il.com>
> ---
>
> Changes V2:
> use type cast to avoid build break for platforms which does not support 64 bit multilplication.
Thanks, pushed to l2-mtd.git
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists