Bug in mtd_speedtest?
David Lambert
dave at lambsys.com
Thu Mar 3 18:45:18 EST 2011
I think I may have found an overflow condition in the speed calculation
of mtd_speedtest on some platforms with larger flash partitions:
Consider for example if goodebcnt = 15000, and mtd->erasesize =
256*1024, then there is an intermediate product of 3932160000 which
results in the sign bit being set on a 32 bit integer. Maybe k should be
an unsigned long long?
.....
static long calc_speed(void)
{
long ms, k, speed;
ms = (finish.tv_sec - start.tv_sec) * 1000 +
(finish.tv_usec - start.tv_usec) / 1000;
k = goodebcnt * mtd->erasesize / 1024;
speed = (k * 1000) / ms;
return speed;
}
.....
More information about the linux-mtd
mailing list