From: Shuah Khan <skhan@linuxfoundation.org>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>, shuah@kernel.org
Cc: chenxiang66@hisilicon.com, iommu@lists.linux.dev,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests/dma:Fix a resource leak
Date: Wed, 10 Jul 2024 09:48:42 -0600 [thread overview]
Message-ID: <0fcefad8-540f-487e-b5b6-b78009bf5d9b@linuxfoundation.org> (raw)
In-Reply-To: <20240710063045.5308-1-zhujun2@cmss.chinamobile.com>
On 7/10/24 00:30, Zhu Jun wrote:
> The opened file should be closed in main(), otherwise resource
> leak will occur that this problem was discovered by reading code
>
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
> tools/testing/selftests/dma/dma_map_benchmark.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/dma/dma_map_benchmark.c b/tools/testing/selftests/dma/dma_map_benchmark.c
> index 5c997f17fcbd..3fcea00961c0 100644
> --- a/tools/testing/selftests/dma/dma_map_benchmark.c
> +++ b/tools/testing/selftests/dma/dma_map_benchmark.c
> @@ -114,6 +114,7 @@ int main(int argc, char **argv)
> map.granule = granule;
>
> if (ioctl(fd, cmd, &map)) {
> + close(fd);
> perror("ioctl");
> exit(1);
> }
> @@ -125,5 +126,7 @@ int main(int argc, char **argv)
> printf("average unmap latency(us):%.1f standard deviation:%.1f\n",
> map.avg_unmap_100ns/10.0, map.unmap_stddev/10.0);
>
> + close(fd);
> +
> return 0;
> }
Files get closed when this process exits. There is no need
to make this change.
thanks,
-- Shuah
prev parent reply other threads:[~2024-07-10 15:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 6:30 Zhu Jun
2024-07-10 15:48 ` 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=0fcefad8-540f-487e-b5b6-b78009bf5d9b@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=chenxiang66@hisilicon.com \
--cc=iommu@lists.linux.dev \
--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®