mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 14:23:49 +01:00
selftests/vm/pkeys: fix alloc_random_pkey() to make it really random
alloc_random_pkey() was allocating the same pkey every time. Not all pkeys were geting tested. This fixes it. Signed-off-by: Ram Pai <[email protected]> Signed-off-by: Sandipan Das <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Dave Hansen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Florian Weimer <[email protected]> Cc: "Desnes A. Nunes do Rosario" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thiago Jung Bauermann <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Michal Suchanek <[email protected]> Cc: Shuah Khan <[email protected]> Link: http://lkml.kernel.org/r/0162f55816d4e783a0d6e49e554d0ab9a3c9a23b.1585646528.git.sandipan@linux.ibm.com Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
ea5f95c3d6
commit
6e373263ce
1 file changed
+2
-1
@@ -25,6 +25,7 @@
|
||||
#define __SANE_USERSPACE_TYPES__
|
||||
#include <errno.h>
|
||||
#include <linux/futex.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <string.h>
|
||||
@@ -546,10 +547,10 @@ int alloc_random_pkey(void)
|
||||
int nr_alloced = 0;
|
||||
int random_index;
|
||||
memset(alloced_pkeys, 0, sizeof(alloced_pkeys));
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
/* allocate every possible key and make a note of which ones we got */
|
||||
max_nr_pkey_allocs = NR_PKEYS;
|
||||
max_nr_pkey_allocs = 1;
|
||||
for (i = 0; i < max_nr_pkey_allocs; i++) {
|
||||
int new_pkey = alloc_pkey();
|
||||
if (new_pkey < 0)
|
||||
|
||||
Reference in new issue
Block a user