]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/mm/cow: fix the incorrect error handling
authorCyan Yang <cyan.yang@sifive.com>
Wed, 12 Mar 2025 04:38:40 +0000 (12:38 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:39:25 +0000 (14:39 +0200)
[ Upstream commit f841ad9ca5007167c02de143980c9dc703f90b3d ]

Error handling doesn't check the correct return value.  This patch will
fix it.

Link: https://lkml.kernel.org/r/20250312043840.71799-1-cyan.yang@sifive.com
Fixes: f4b5fd6946e2 ("selftests/vm: anon_cow: THP tests")
Signed-off-by: Cyan Yang <cyan.yang@sifive.com>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/mm/cow.c

index 1238e1c5aae150568b64cf5837f86b1499695181..d87c5b1763ff153f95296b07571ec73d8ef4f9d5 100644 (file)
@@ -876,7 +876,7 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)
                mremap_size = thpsize / 2;
                mremap_mem = mmap(NULL, mremap_size, PROT_NONE,
                                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-               if (mem == MAP_FAILED) {
+               if (mremap_mem == MAP_FAILED) {
                        ksft_test_result_fail("mmap() failed\n");
                        goto munmap;
                }