The patch titled Subject: tools/testing/selftests/vm/ksm_tests.c: fix resource leak when return error has been added to the -mm mm-unstable branch. Its filename is selftests-vm-fix-resource-leak-when-return-error.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-vm-fix-resource-leak-when-return-error.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Ding Xiang <dingxiang@xxxxxxxxxxxxxxxxxxxx> Subject: tools/testing/selftests/vm/ksm_tests.c: fix resource leak when return error Date: Wed, 15 Jun 2022 17:36:29 +0800 When return on an error path, file handle need to be closed to prevent resource leak Link: https://lkml.kernel.org/r/20220615093629.1330809-1-dingxiang@xxxxxxxxxxxxxxxxxxxx Signed-off-by: Ding Xiang <dingxiang@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/vm/ksm_tests.c | 2 ++ 1 file changed, 2 insertions(+) --- a/tools/testing/selftests/vm/ksm_tests.c~selftests-vm-fix-resource-leak-when-return-error +++ a/tools/testing/selftests/vm/ksm_tests.c @@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *f } if (fprintf(f, "%lu", val) < 0) { perror("fprintf"); + fclose(f); return 1; } fclose(f); @@ -72,6 +73,7 @@ static int ksm_read_sysfs(const char *fi } if (fscanf(f, "%lu", val) != 1) { perror("fscanf"); + fclose(f); return 1; } fclose(f); _ Patches currently in -mm which might be from dingxiang@xxxxxxxxxxxxxxxxxxxx are selftests-vm-fix-resource-leak-when-return-error.patch