overflows while calculating volume->used_bytes

Artem Bityutskiy dedekind at infradead.org
Tue Jul 10 03:01:08 EDT 2007


Vinit,

On Tue, 2007-07-10 at 11:07 +0530, Vinit Agnihotri wrote:
> I was experiencing overflows in multiplications for
> volume->used_bytes in vmt.c & vtbl.c, while creating & resizing large volumes.
> 
> vol->used_bytes is long long however its 2 operands vol->used_ebs &
> vol->usable_leb_size
> are int. So their multiplication for larger values causes integer overflows.
> Typecasting them solves the problem.
> 
> My machine & flash details:
> 
> 64Bit dual-core AMD opteron, 1 GB RAM, linux 2.6.18.3.
> mtd size = 6GB, volume size= 5GB, peb_size = 4MB.
> 
> heres patch which does the fix.

Thanks for the patch. Just one note:

you can add only one (long long) prefix before the first operand, no
need to add it to the second one and make the line too long so that
you need to split it.

> +		vol->used_bytes = (long long)vol->used_ebs *
> +							(long long)vol->usable_leb_size;

Like here it could be
 +		vol->used_bytes = (long long)vol->used_ebs * vol->usable_leb_size;

Otherwise the patch looks good. Will you resend it or you are fine if I
amend it myself?

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list