From: Shuah Khan <skhan@linuxfoundation.org>
To: Ding Xiang <dingxiang@cmss.chinamobile.com>,
akpm@linux-foundation.org, shuah@kernel.org
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests: vm: Fix resource leak when return error
Date: Thu, 16 Jun 2022 14:19:54 -0600 [thread overview]
Message-ID: <c2d63817-dc5b-13eb-2698-4ca39bd0d1c1@linuxfoundation.org> (raw)
In-Reply-To: <29be48c7-7178-6f25-c99b-0d11eb967539@linuxfoundation.org>
On 6/16/22 2:11 PM, Shuah Khan wrote:
> On 6/15/22 3:36 AM, Ding Xiang wrote:
>> When return on an error path, file handle need to be closed
>> to prevent resource leak
>>
>> Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
>> ---
>> tools/testing/selftests/vm/ksm_tests.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/testing/selftests/vm/ksm_tests.c b/tools/testing/selftests/vm/ksm_tests.c
>> index 2fcf24312da8..f5e4e0bbd081 100644
>> --- a/tools/testing/selftests/vm/ksm_tests.c
>> +++ b/tools/testing/selftests/vm/ksm_tests.c
>> @@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *file_path, unsigned long val)
>> }
>> 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 *file_path, unsigned long *val)
>> }
>> if (fscanf(f, "%lu", val) != 1) {
>> perror("fscanf");
>> + fclose(f);
>> return 1;
>> }
>> fclose(f);
>>
>
> Looks good to me.
>
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>
I applied this to linux-kselftest fixes for next rc.
thanks,
-- Shuah
prev parent reply other threads:[~2022-06-16 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 9:36 Ding Xiang
2022-06-16 20:11 ` Shuah Khan
2022-06-16 20:19 ` Shuah Khan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2d63817-dc5b-13eb-2698-4ca39bd0d1c1@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=dingxiang@cmss.chinamobile.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox