From: Shuah Khan <skhan@linuxfoundation.org>
To: liujing <liujing@cmss.chinamobile.com>,
shuah@kernel.org, osmtendev@gmail.com
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests: prctl: Fix resource leaks
Date: Wed, 4 Dec 2024 16:00:44 -0700 [thread overview]
Message-ID: <f0fc34fa-d208-4bd2-8e0d-bfba60b06b90@linuxfoundation.org> (raw)
In-Reply-To: <20241128061827.4165-1-liujing@cmss.chinamobile.com>
On 11/27/24 23:18, liujing wrote:
> After using the fopen function successfully, you need to call
> fclose to close the file before finally returning.
>
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
>
> diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c
> index 562f707ba771..7be7afff0cd2 100644
> --- a/tools/testing/selftests/prctl/set-process-name.c
> +++ b/tools/testing/selftests/prctl/set-process-name.c
> @@ -66,9 +66,12 @@ int check_name(void)
> return -EIO;
>
> fscanf(fptr, "%s", output);
> - if (ferror(fptr))
> + if (ferror(fptr)) {
> + fclose(fptr);
> return -EIO;
> + }
>
> + fclose(fptr);
> int res = prctl(PR_GET_NAME, name, NULL, NULL, NULL);
>
> if (res < 0)
How did you find this problem? This file will be closed when
the test exits - do you need this fclose()?
thanks,
-- Shuah
prev parent reply other threads:[~2024-12-04 23:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 6:18 [PATCH] selftests: prctl: Fix resource leaks liujing
2024-12-04 23:00 ` 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=f0fc34fa-d208-4bd2-8e0d-bfba60b06b90@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=liujing@cmss.chinamobile.com \
--cc=osmtendev@gmail.com \
--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