mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: zhujun2 <zhujun2@cmss.chinamobile.com>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org, Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests/efivarfs: create-read: fix a resource leak
Date: Wed, 18 Oct 2023 13:08:00 -0600	[thread overview]
Message-ID: <662a7ca4-beee-4ea3-b77e-4d5af1462f13@linuxfoundation.org> (raw)
In-Reply-To: <20231018015921.16890-1-zhujun2@cmss.chinamobile.com>

On 10/17/23 19:59, zhujun2 wrote:
> The opened file should be closed in main(), otherwise resource
> leak will occur that this problem was discovered by code reading
> 
> Signed-off-by: zhujun2 <zhujun2@cmss.chinamobile.com>
> ---
>   tools/testing/selftests/efivarfs/create-read.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c
> index 9674a1939..7bc7af4eb 100644
> --- a/tools/testing/selftests/efivarfs/create-read.c
> +++ b/tools/testing/selftests/efivarfs/create-read.c
> @@ -32,8 +32,10 @@ int main(int argc, char **argv)
>   	rc = read(fd, buf, sizeof(buf));
>   	if (rc != 0) {
>   		fprintf(stderr, "Reading a new var should return EOF\n");
> +		close(fd);
>   		return EXIT_FAILURE;
>   	}
>   
> +	close(fd);
>   	return EXIT_SUCCESS;
>   }

Thank you. Applied to linux-kselftest next for Linux 6.7-c1.

thanks,
-- Shuah

      reply	other threads:[~2023-10-18 19:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17  2:33 zhujun2
2023-10-17 15:46 ` Shuah Khan
2023-10-18  1:59   ` zhujun2
2023-10-18 19:08     ` 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=662a7ca4-beee-4ea3-b77e-4d5af1462f13@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=zhujun2@cmss.chinamobile.com \
    /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

all inboxes | Powered by JetHome®