All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma/dma_map_benchmark: fix fd leak on error and exit
@ 2026-05-21  8:02 2564278112
  2026-05-21  9:32 ` David Laight
  0 siblings, 1 reply; 3+ messages in thread
From: 2564278112 @ 2026-05-21  8:02 UTC (permalink / raw)
  To: Barry Song, Qinxin Xia; +Cc: Marek Szyprowski, Wang Jiang, iommu, linux-kernel

From: Wang Jiang <jiangwang@kylinos.cn>

Close the file descriptor when ioctl fails and on normal exit
to fix file descriptor leak.

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;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-25  1:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.