From: Mats Kärrman Date: Wed, 21 Aug 2013 13:24:49 +0000 (+0000) Subject: UBIFS: correct data corruption range X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=58a4e23703b22c331b01fbd0c12161aadaa6d50b;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Signed-off-by: Artem Bityutskiy --- diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 6e025e02ffde..cc1febd8fadf 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -2563,9 +2563,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf, unsigned int from, to, ffs = chance(1, 2); unsigned char *p = (void *)buf; - from = prandom_u32() % (len + 1); - /* Corruption may only span one max. write unit */ - to = min(len, ALIGN(from, c->max_write_size)); + from = prandom_u32() % len; + /* Corruption span max to end of write unit */ + to = min(len, ALIGN(from + 1, c->max_write_size)); ubifs_warn("filled bytes %u-%u with %s", from, to - 1, ffs ? "0xFFs" : "random data");