[PATCH] selftests/dma:Fix a resource leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
---
 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







[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux