summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDing Xiang <dingxiang@cmss.chinamobile.com>2023-08-31 17:31:44 +0800
committerAndrew Morton <akpm@linux-foundation.org>2023-10-04 10:32:19 -0700
commitb6afcb94ce331b6d94dbeb56def173483993faf3 (patch)
tree410443c07b47c79bdcd67f595ec80f97f08f894c
parente19a3f595ae47bd8c034b98eb0b28a3877413387 (diff)
selftests/mm: gup_longterm: fix a resource leak
The opened file should be closed in run_with_tmpfile(), otherwise resource leak will occur Link: https://lkml.kernel.org/r/20230831093144.7520-1-dingxiang@cmss.chinamobile.com Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--tools/testing/selftests/mm/gup_longterm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
index d33d3e68ffab..ad168d35b23b 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -265,10 +265,11 @@ static void run_with_tmpfile(test_fn fn, const char *desc)
fd = fileno(file);
if (fd < 0) {
ksft_test_result_fail("fileno() failed\n");
- return;
+ goto close;
}
fn(fd, pagesize);
+close:
fclose(file);
}