Skip to content

Commit cdd9fa8

Browse files
mitatorvalds
authored andcommitted
ubifs: use prandom_bytes
This also converts filling memory loop to use memset. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Artem Bityutskiy <dedekind1@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: David Laight <david.laight@aculab.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Eilon Greenstein <eilong@broadcom.com> Cc: Michel Lespinasse <walken@google.com> Cc: Robert Love <robert.w.love@intel.com> Cc: Valdis Kletnieks <valdis.kletnieks@vt.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7e45bf8 commit cdd9fa8

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎fs/ubifs/debug.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write)
25602560
static int corrupt_data(const struct ubifs_info *c, const void *buf,
25612561
unsigned int len)
25622562
{
2563-
unsigned int from, to, i, ffs = chance(1, 2);
2563+
unsigned int from, to, ffs = chance(1, 2);
25642564
unsigned char *p = (void *)buf;
25652565

25662566
from = random32() % (len + 1);
@@ -2571,11 +2571,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
25712571
ffs ? "0xFFs" : "random data");
25722572

25732573
if (ffs)
2574-
for (i = from; i < to; i++)
2575-
p[i] = 0xFF;
2574+
memset(p + from, 0xFF, to - from);
25762575
else
2577-
for (i = from; i < to; i++)
2578-
p[i] = random32() % 0x100;
2576+
prandom_bytes(p + from, to - from);
25792577

25802578
return to;
25812579
}

0 commit comments

Comments
 (0)