]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mtd: tests: stresstest: bail out if device has not enough eraseblocks
authorWolfram Sang <w.sang@pengutronix.de>
Tue, 29 Nov 2011 14:34:08 +0000 (15:34 +0100)
committerArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
Thu, 8 Dec 2011 21:49:56 +0000 (23:49 +0200)
commitd2feec5f85500aa8462ee12a673a10b7f149e72c
tree4b0e97ec67b2b9e895f297d6605fdfba3c94ba66
parent8767db0ab5bddb206672791fee3e87fea2214689
mtd: tests: stresstest: bail out if device has not enough eraseblocks

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);

Cc: stable@kernel.org
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
drivers/mtd/tests/mtd_stresstest.c