mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-01 00:36:40 +09:00
mtd: tests: stresstest: bail out if device has not enough eraseblocks
commit 2f4478ccff upstream.
stresstest needs at least two eraseblocks. Bail out gracefully if that
condition is not met. Fixes the following 'division by zero' OOPS:
[ 619.100000] mtd_stresstest: MTD device size 131072, eraseblock size 131072, page size 2048, count of eraseblocks 1, pages per eraseblock 64, OOB size 64
[ 619.120000] mtd_stresstest: scanning for bad eraseblocks
[ 619.120000] mtd_stresstest: scanned 1 eraseblocks, 0 are bad
[ 619.130000] mtd_stresstest: doing operations
[ 619.130000] mtd_stresstest: 0 operations done
[ 619.140000] Division by zero in kernel.
...
caused by
/* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */
eb %= (ebcnt - 1);
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4eb4226e5e
commit
0fbc846f71
@@ -284,6 +284,12 @@ static int __init mtd_stresstest_init(void)
|
||||
(unsigned long long)mtd->size, mtd->erasesize,
|
||||
pgsize, ebcnt, pgcnt, mtd->oobsize);
|
||||
|
||||
if (ebcnt < 2) {
|
||||
printk(PRINT_PREF "error: need at least 2 eraseblocks\n");
|
||||
err = -ENOSPC;
|
||||
goto out_put_mtd;
|
||||
}
|
||||
|
||||
/* Read or write up 2 eraseblocks at a time */
|
||||
bufsize = mtd->erasesize * 2;
|
||||
|
||||
@@ -322,6 +328,7 @@ out:
|
||||
kfree(bbt);
|
||||
vfree(writebuf);
|
||||
vfree(readbuf);
|
||||
out_put_mtd:
|
||||
put_mtd_device(mtd);
|
||||
if (err)
|
||||
printk(PRINT_PREF "error %d occurred\n", err);
|
||||
|
||||
Reference in New Issue
Block a user