public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Bug in mtd_speedtest?
@ 2011-03-03 23:45 David Lambert
  2011-03-04  6:59 ` Artem Bityutskiy
  0 siblings, 1 reply; 5+ messages in thread
From: David Lambert @ 2011-03-03 23:45 UTC (permalink / raw)
  To: linux-mtd@lists.infradead.org

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;
}
.....

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-07 10:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-03 23:45 Bug in mtd_speedtest? David Lambert
2011-03-04  6:59 ` Artem Bityutskiy
2011-03-04 17:53   ` David Lambert
2011-03-07  4:11     ` Jon Povey
2011-03-07 10:09     ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox