diff options
author | Richard Genoud <richard.genoud@gmail.com> | 2014-06-24 12:12:58 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-06-25 16:37:37 +0200 |
commit | cbf3bfa57a419202c2bc26f3ff8ae21d3d3bf8b2 (patch) | |
tree | a068db7e2be4e0edeaecead5ca210be0c48001d7 /miscutils | |
parent | de3cae1348f212effd3f2838301596d15c6b3e54 (diff) | |
download | busybox-w32-cbf3bfa57a419202c2bc26f3ff8ae21d3d3bf8b2.tar.gz busybox-w32-cbf3bfa57a419202c2bc26f3ff8ae21d3d3bf8b2.tar.bz2 busybox-w32-cbf3bfa57a419202c2bc26f3ff8ae21d3d3bf8b2.zip |
nanddump: correct rounding to next page (lead to infinite loop)
The rounding to next page formula was wrong:
ex: (len | ~(meminfo->writesize - 1)) + 1;
len=128K
writesize=4K
(len | ~(meminfo->writesize - 1)) + 1 => 4 294 963 201 ?!
correct rounding formula:
((len - 1) | (meminfo->writesize - 1)) + 1 => 128K
len = 130K
((len - 1) | (meminfo->writesize - 1)) + 1 => 132K
modprobe nandsim parts="20,20" badblocks="22,23"
without patch:
nanddump /dev/mtd1 | wc -c
[...] infinite loop
with the patch:
nanddump /dev/mtd1 | wc -c
327680
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/nandwrite.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c index e3f9b565d..8c4da802f 100644 --- a/miscutils/nandwrite.c +++ b/miscutils/nandwrite.c | |||
@@ -64,8 +64,8 @@ static void dump_bad(struct mtd_info_user *meminfo, unsigned len, int oob) | |||
64 | unsigned char buf[meminfo->writesize]; | 64 | unsigned char buf[meminfo->writesize]; |
65 | unsigned count; | 65 | unsigned count; |
66 | 66 | ||
67 | /* round len to the next page */ | 67 | /* round len to the next page only if len is not already on a page */ |
68 | len = (len | ~(meminfo->writesize - 1)) + 1; | 68 | len = ((len - 1) | (meminfo->writesize - 1)) + 1; |
69 | 69 | ||
70 | memset(buf, 0xff, sizeof(buf)); | 70 | memset(buf, 0xff, sizeof(buf)); |
71 | for (count = 0; count < len; count += meminfo->writesize) { | 71 | for (count = 0; count < len; count += meminfo->writesize) { |