Message ID | 20250114023838.48589-1-liuye@kylinos.cn (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | selftests/mm/mkdirty: Fix memory leak in test_uffdio_copy() | expand |
On 14.01.25 03:38, liuye wrote: > Release memory before exception branch returns to prevent memory leaks > > Checking tools/testing/selftests/mm/mkdirty.c ... > tools/testing/selftests/mm/mkdirty.c:283:3: error: Memory leak: src [memleak] > return; > ^ Don't take this the wrong way: there must be something better to be done with your time than fixing memory leaks on exit paths in tests. > > Signed-off-by: liuye <liuye@kylinos.cn> > --- > tools/testing/selftests/mm/mkdirty.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c > index 1db134063c38..af2fce496912 100644 > --- a/tools/testing/selftests/mm/mkdirty.c > +++ b/tools/testing/selftests/mm/mkdirty.c > @@ -280,6 +280,7 @@ static void test_uffdio_copy(void) > dst = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0); > if (dst == MAP_FAILED) { > ksft_test_result_fail("mmap() failed\n"); > + free(src); We are immediately exiting the test afterwards ... In any case, the change LGTM Reviewed-by: David Hildenbrand <david@redhat.com>
diff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c index 1db134063c38..af2fce496912 100644 --- a/tools/testing/selftests/mm/mkdirty.c +++ b/tools/testing/selftests/mm/mkdirty.c @@ -280,6 +280,7 @@ static void test_uffdio_copy(void) dst = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0); if (dst == MAP_FAILED) { ksft_test_result_fail("mmap() failed\n"); + free(src); return; }
Release memory before exception branch returns to prevent memory leaks Checking tools/testing/selftests/mm/mkdirty.c ... tools/testing/selftests/mm/mkdirty.c:283:3: error: Memory leak: src [memleak] return; ^ Signed-off-by: liuye <liuye@kylinos.cn> --- tools/testing/selftests/mm/mkdirty.c | 1 + 1 file changed, 1 insertion(+)