[igt-dev] [PATCH i-g-t 1/1] tests: update the test with close() for prime fd

Mohammed Khajapasha mohammed.khajapasha at intel.com
Thu Jan 9 07:04:41 UTC 2020


Include close() for prime file descriptor and
call mumap() in mmap() success case only.

Signed-off-by: Mohammed Khajapasha <mohammed.khajapasha at intel.com>
---
 tests/prime_mmap_kms.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/prime_mmap_kms.c b/tests/prime_mmap_kms.c
index 29aec499..746e2abe 100644
--- a/tests/prime_mmap_kms.c
+++ b/tests/prime_mmap_kms.c
@@ -207,6 +207,9 @@ static void run_test(gpu_process_t *gpu)
 		igt_waitchildren();
 
 		igt_debug_wait_for_keypress("paint");
+
+		close(prime_fd);
+
 		cleanup_crtc(gpu);
 
 		/* once is enough */
@@ -227,11 +230,12 @@ check_for_dma_buf_mmap(int fd)
 	handle = gem_create(fd, 4096);
 	dma_buf_fd = prime_handle_to_fd(fd, handle);
 	ptr = mmap(NULL, 4096, PROT_READ, MAP_SHARED, dma_buf_fd, 0);
-	if (ptr != MAP_FAILED)
+	if (ptr != MAP_FAILED) {
 		ret = 0;
-	munmap(ptr, 4096);
-	gem_close(fd, handle);
+		munmap(ptr, 4096);
+	}
 	close(dma_buf_fd);
+	gem_close(fd, handle);
 	return ret;
 }
 
-- 
2.24.1



More information about the igt-dev mailing list