[LTP] [PATCH 1/1] hugemmap24: Postpone free()
Petr Vorel
pvorel@suse.cz
Tue Jan 30 10:28:44 CET 2024
This fixes warning: pointer ‘heap’ used after ‘free’.
Pointer is not used anyway, but better to avoid warning.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/mem/hugetlb/hugemmap/hugemmap24.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap24.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap24.c
index 431dc1bbf..3ba0985dc 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap24.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap24.c
@@ -42,7 +42,6 @@ static int init_slice_boundary(int fd)
/* dummy malloc so we know where is heap */
heap = malloc(1);
- free(heap);
/* Avoid underflow on systems with large huge pages.
* The additionally plus heap address is to reduce the possibility
@@ -51,6 +50,8 @@ static int init_slice_boundary(int fd)
while (slice_boundary + slice_size < (unsigned long)heap + 2*hpage_size)
slice_boundary += slice_size;
+ free(heap);
+
/* Find 2 neighbour slices with couple huge pages free
* around slice boundary.
* 16 is the maximum number of slices (low/high)
--
2.43.0
More information about the ltp
mailing list