]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/vm: fix map_hugetlb length used for testing read and write
authorChristophe Leroy <christophe.leroy@c-s.fr>
Thu, 2 Apr 2020 04:11:51 +0000 (21:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:50:19 +0000 (10:50 +0200)
commit0ac23b0cd6b4e99f04c73d8e973791340c2e1c86
treec11ac1f4b1a74b0d1ead8fae15f5706ee3edb750
parent9c80f8e306747b7696cccfb2cc1c02a3bdb88d19
selftests/vm: fix map_hugetlb length used for testing read and write

commit 69e7bae744d9d21bc8936c81fd7fbf8d1ff6f1e0 upstream.

Commit f3cdbe13bf63 ("tools/selftest/vm: allow choosing mem size and page
size in map_hugetlb") added the possibility to change the size of memory
mapped for the test, but left the read and write test using the default
value.  This is unnoticed when mapping a length greater than the default
one, but segfaults otherwise.

Fix read_bytes() and write_bytes() by giving them the real length.

Also fix the call to munmap().

Fixes: f3cdbe13bf63 ("tools/selftest/vm: allow choosing mem size and page size in map_hugetlb")
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Leonardo Bras <leonardo@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/9a404a13c871c4bd0ba9ede68f69a1225180dd7e.1580978385.git.christophe.leroy@c-s.fr
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/vm/map_hugetlb.c