]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - tools/testing/selftests/powerpc/mm/hugetlb_vs_thp_test.c
mm, selftests: test return value of munmap for MAP_HUGETLB memory
[mirror_ubuntu-jammy-kernel.git] / tools / testing / selftests / powerpc / mm / hugetlb_vs_thp_test.c
index 3d8e5b033e1d1e06b68a0d81fd4ef938d9260c93..49003674de4fa3d2e0856dacf7dc3f51cee62132 100644 (file)
@@ -21,9 +21,13 @@ static int test_body(void)
                 * Typically the mmap will fail because no huge pages are
                 * allocated on the system. But if there are huge pages
                 * allocated the mmap will succeed. That's fine too, we just
-                * munmap here before continuing.
+                * munmap here before continuing.  munmap() length of
+                * MAP_HUGETLB memory must be hugepage aligned.
                 */
-               munmap(addr, SIZE);
+               if (munmap(addr, SIZE)) {
+                       perror("munmap");
+                       return 1;
+               }
        }
 
        p = mmap(addr, SIZE, PROT_READ | PROT_WRITE,