mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/dma:Fix a resource leak
@ 2024-07-10  6:30 Zhu Jun
  2024-07-10 15:48 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2024-07-10  6:30 UTC (permalink / raw)
  To: shuah; +Cc: zhujun2, chenxiang66, iommu, linux-kselftest, linux-kernel

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




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

end of thread, other threads:[~2024-07-10 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-10  6:30 [PATCH] selftests/dma:Fix a resource leak Zhu Jun
2024-07-10 15:48 ` Shuah Khan

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®