linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: tests: stresstest: bail out if device has not enough eraseblocks
@ 2011-11-29 14:34 Wolfram Sang
  2011-12-04 13:50 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2011-11-29 14:34 UTC (permalink / raw)
  To: linux-mtd; +Cc: Wolfram Sang, Artem Bityutskiy

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>
---
 drivers/mtd/tests/mtd_stresstest.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 52ffd91..811642f 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -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);
-- 
1.7.7.3

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

* Re: [PATCH] mtd: tests: stresstest: bail out if device has not enough eraseblocks
  2011-11-29 14:34 [PATCH] mtd: tests: stresstest: bail out if device has not enough eraseblocks Wolfram Sang
@ 2011-12-04 13:50 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2011-12-04 13:50 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

On Tue, 2011-11-29 at 15:34 +0100, Wolfram Sang wrote:
> 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.

Hi, thanks, added
Cc: stable@kernel.org
and pushed to l2-mtd-2.6.git.

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2011-12-04 13:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 14:34 [PATCH] mtd: tests: stresstest: bail out if device has not enough eraseblocks Wolfram Sang
2011-12-04 13:50 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).