Skip to content

Commit 58a4e23

Browse files
Mats Kärrmandedekind
authored andcommitted
UBIFS: correct data corruption range
With power-cut emulation, it is possible that sometimes no data at all is corrupted and that confusing messages are printed due to errors in the computation of data corruption range. [1] The start of the range should be [0..len-1], not [0..len]. [2] The end of the range should always be at least 1 greater than the start. Signed-off-by: Mats Karrman <mats.karrman@tritech.se> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent 7203db9 commit 58a4e23

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎fs/ubifs/debug.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,9 +2563,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
25632563
unsigned int from, to, ffs = chance(1, 2);
25642564
unsigned char *p = (void *)buf;
25652565

2566-
from = prandom_u32() % (len + 1);
2567-
/* Corruption may only span one max. write unit */
2568-
to = min(len, ALIGN(from, c->max_write_size));
2566+
from = prandom_u32() % len;
2567+
/* Corruption span max to end of write unit */
2568+
to = min(len, ALIGN(from + 1, c->max_write_size));
25692569

25702570
ubifs_warn("filled bytes %u-%u with %s", from, to - 1,
25712571
ffs ? "0xFFs" : "random data");

0 commit comments

Comments
 (0)