All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>
Cc: shuah@kernel.org, linux-rtc@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/rtc:Fix a resource leak
Date: Wed, 10 Jul 2024 09:16:50 +0200	[thread overview]
Message-ID: <20240710071650f7265b40@mail.local> (raw)
In-Reply-To: <20240710060743.4691-1-zhujun2@cmss.chinamobile.com>

On 09/07/2024 23:07:43-0700, Zhu Jun wrote:
> The opened file should be closed before exit, otherwise resource leak
> will occur that this problem was discovered by reading code

Can you elaborate on the leak? All the fds are getting closed on exit.

> 
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
>  tools/testing/selftests/rtc/setdate.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/rtc/setdate.c b/tools/testing/selftests/rtc/setdate.c
> index b303890b3de2..17a00affb0ec 100644
> --- a/tools/testing/selftests/rtc/setdate.c
> +++ b/tools/testing/selftests/rtc/setdate.c
> @@ -65,6 +65,7 @@ int main(int argc, char **argv)
>  	retval = ioctl(fd, RTC_RD_TIME, &current);
>  	if (retval == -1) {
>  		perror("RTC_RD_TIME ioctl");
> +		close(fd);
>  		exit(errno);
>  	}
>  
> -- 
> 2.17.1
> 
> 
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2024-07-10  7:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10  6:07 [PATCH] selftests/rtc:Fix a resource leak Zhu Jun
2024-07-10  7:16 ` Alexandre Belloni [this message]
2024-07-10  7:43   ` [PATCH v2] " Zhu Jun
2024-07-10  7:55     ` Alexandre Belloni
2024-07-10 16:00       ` Shuah Khan
2024-07-16 17:58         ` John Hubbard

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=20240710071650f7265b40@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rtc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.