From: Qinxin Xia <xiaqinxin@huawei.com>
To: David Laight <david.laight.linux@gmail.com>, <2564278112@qq.com>
Cc: Barry Song <baohua@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Wang Jiang <jiangwang@kylinos.cn>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dma/dma_map_benchmark: fix fd leak on error and exit
Date: Mon, 25 May 2026 09:44:24 +0800 [thread overview]
Message-ID: <e873ad08-7feb-453e-a74f-e4e87a06d40b@huawei.com> (raw)
In-Reply-To: <20260521103236.747dceef@pumpkin>
On 2026/5/21 17:32:36, David Laight <david.laight.linux@gmail.com> wrote:
> On Thu, 21 May 2026 16:02:41 +0800
> 2564278112@qq.com wrote:
>
>> From: Wang Jiang <jiangwang@kylinos.cn>
>>
>> Close the file descriptor when ioctl fails and on normal exit
>> to fix file descriptor leak.
>
> There isn't a leak, it is all tidied up by the kernel.
>
> -- David
>
>>
>> Signed-off-by: Wang Jiang <jiangwang@kylinos.cn>
>> ---
>> tools/dma/dma_map_benchmark.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/dma/dma_map_benchmark.c b/tools/dma/dma_map_benchmark.c
>> index eab0ac611a23..bdb8a837f020 100644
>> --- a/tools/dma/dma_map_benchmark.c
>> +++ b/tools/dma/dma_map_benchmark.c
>> @@ -130,6 +130,7 @@ int main(int argc, char **argv)
>>
>> if (ioctl(fd, cmd, &map)) {
>> perror("ioctl");
>> + close(fd);
>> exit(1);
>> }
>>
>> @@ -140,5 +141,6 @@ 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;
>> }
>
Thanks for the patch, but as David said, the kernel cleans up on exit,
so no leak. I'd prefer to leave it as is. :-)
--
Thanks,
Qinxin
prev parent reply other threads:[~2026-05-25 1:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 8:02 [PATCH] dma/dma_map_benchmark: fix fd leak on error and exit 2564278112
2026-05-21 9:32 ` David Laight
2026-05-25 1:44 ` Qinxin Xia [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=e873ad08-7feb-453e-a74f-e4e87a06d40b@huawei.com \
--to=xiaqinxin@huawei.com \
--cc=2564278112@qq.com \
--cc=baohua@kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=jiangwang@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.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