[PATCH i-g-t 4/7] Sprinkle igt_assert(ptr) after gem_mmap__{cpu, gtt, wc}

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

 



From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

Do the following
 ptr = gem_mmap__{cpu,gtt,wc}()
+igt_assert(ptr);

whenever the code doesn't handle the NULL ptr in any kind of
specific way.

Makes it easier to move the assert into gem_mmap__{cpu,gtt,wc}() itself.

Mostly done with coccinelle, with some manual cleanups:
@@
identifier I;
@@
<... when != igt_assert(I)
     when != igt_require(I)
     when != igt_require_f(I, ...)
     when != I != NULL
     when != I == NULL
(
  I = gem_mmap__gtt(...);
+ igt_assert(I);
|
  I = gem_mmap__cpu(...);
+ igt_assert(I);
|
  I = gem_mmap__wc(...);
+ igt_assert(I);
)
...>

Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
---
 benchmarks/gem_blt.c           |  1 +
 benchmarks/gem_mmap.c          |  3 +++
 tests/gem_cs_tlb.c             |  1 +
 tests/gem_exec_lut_handle.c    |  1 +
 tests/gem_gtt_cpu_tlb.c        |  2 ++
 tests/gem_gtt_hog.c            |  5 ++++-
 tests/gem_gtt_speed.c          | 18 ++++++++++++++++++
 tests/gem_largeobject.c        |  1 +
 tests/gem_mmap.c               |  1 +
 tests/gem_pwrite_pread.c       |  8 ++++++++
 tests/gem_streaming_writes.c   |  8 ++++++--
 tests/gem_tiled_pread_basic.c  |  1 +
 tests/gem_tiled_pread_pwrite.c |  2 ++
 tests/gem_tiled_swapping.c     |  1 +
 tests/gem_tiled_wb.c           |  1 +
 tests/gem_tiled_wc.c           |  1 +
 tests/gem_userptr_blits.c      |  2 ++
 tests/gen7_forcewake_mt.c      |  1 +
 tests/kms_fbc_crc.c            |  2 ++
 tests/kms_fence_pin_leak.c     |  1 +
 tests/kms_psr_sink_crc.c       |  3 +++
 tests/pm_rpm.c                 | 18 ++++++++++++++----
 tests/prime_self_import.c      |  4 ++--
 23 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
index 181a5f1..3ed2300 100644
--- a/benchmarks/gem_blt.c
+++ b/benchmarks/gem_blt.c
@@ -178,6 +178,7 @@ static int run(int object, int batch, int count, int reps)
 	fd = drm_open_driver(DRIVER_INTEL);
 	handle = gem_create(fd, size);
 	buf = gem_mmap__cpu(fd, handle, 0, size, PROT_WRITE);
+	igt_assert(buf);
 
 	gen = intel_gen(intel_get_drm_devid(fd));
 	has_64bit_reloc = gen >= 8;
diff --git a/benchmarks/gem_mmap.c b/benchmarks/gem_mmap.c
index bc26d31..6bf7fd3 100644
--- a/benchmarks/gem_mmap.c
+++ b/benchmarks/gem_mmap.c
@@ -116,14 +116,17 @@ int main(int argc, char **argv)
 	switch (map) {
 	case CPU:
 		ptr = gem_mmap__cpu(fd, handle, 0, OBJECT_SIZE, PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
 		break;
 	case GTT:
 		ptr = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		break;
 	case WC:
 		ptr = gem_mmap__wc(fd, handle, 0, OBJECT_SIZE, PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		break;
 	default:
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 8b640fa..a647ddf 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -117,6 +117,7 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
 		handle_new = gem_create(fd, BATCH_SIZE);
 		batch_ptr = gem_mmap__cpu(fd, handle_new, 0, BATCH_SIZE,
 					  PROT_READ | PROT_WRITE);
+		igt_assert(batch_ptr);
 		batch_ptr[split*2] = MI_BATCH_BUFFER_END;
 
 		for (i = split*2 + 2; i < BATCH_SIZE/8; i++)
diff --git a/tests/gem_exec_lut_handle.c b/tests/gem_exec_lut_handle.c
index 875fea2..282fccf 100644
--- a/tests/gem_exec_lut_handle.c
+++ b/tests/gem_exec_lut_handle.c
@@ -124,6 +124,7 @@ igt_simple_main
 	size = ALIGN(sizeof(mem_reloc), 4096);
 	reloc_handle = gem_create(fd, size);
 	reloc = gem_mmap__cpu(fd, reloc_handle, 0, size, PROT_READ | PROT_WRITE);
+	igt_assert(reloc);
 	for (n = 0; n < MAX_NUM_RELOC; n++) {
 		reloc[n].offset = 1024;
 		reloc[n].read_domains = I915_GEM_DOMAIN_RENDER;
diff --git a/tests/gem_gtt_cpu_tlb.c b/tests/gem_gtt_cpu_tlb.c
index 8ceef44..75c3d04 100644
--- a/tests/gem_gtt_cpu_tlb.c
+++ b/tests/gem_gtt_cpu_tlb.c
@@ -60,6 +60,7 @@ create_bo(int fd)
 
 	/* Fill the BO with dwords starting at start_val */
 	data = gem_mmap__gtt(fd, handle, OBJ_SIZE, PROT_READ | PROT_WRITE);
+	igt_assert(data);
 	for (i = 0; i < OBJ_SIZE/4; i++)
 		data[i] = i;
 	munmap(data, OBJ_SIZE);
@@ -83,6 +84,7 @@ igt_simple_main
 
 	/* touch one page */
 	ptr = gem_mmap__gtt(fd, handle, OBJ_SIZE, PROT_READ | PROT_WRITE);
+	igt_assert(ptr);
 	*ptr = 0xdeadbeef;
 	munmap(ptr, OBJ_SIZE);
 
diff --git a/tests/gem_gtt_hog.c b/tests/gem_gtt_hog.c
index b0673a4..cbb7016 100644
--- a/tests/gem_gtt_hog.c
+++ b/tests/gem_gtt_hog.c
@@ -141,9 +141,12 @@ static void run(data_t *data, int child)
 	 */
 	if (write) {
 		ptr = gem_mmap__gtt(data->fd, handle, size, PROT_READ | PROT_WRITE);
+		igt_assert(ptr);
 		ptr[rand() % (size / 4)] = canary;
-	} else
+	} else {
 		ptr = gem_mmap__gtt(data->fd, handle, size, PROT_READ);
+		igt_assert(ptr);
+	}
 	x = ptr[rand() % (size / 4)];
 	munmap(ptr, size);
 
diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c
index bcca1f4..ed45bba 100644
--- a/tests/gem_gtt_speed.c
+++ b/tests/gem_gtt_speed.c
@@ -93,6 +93,8 @@ int main(int argc, char **argv)
 				volatile uint32_t *ptr = base;
 				int x = 0;
 
+				igt_assert(base);
+
 				for (i = 0; i < size/sizeof(*ptr); i++)
 					x += ptr[i];
 
@@ -108,6 +110,8 @@ int main(int argc, char **argv)
 					ptr = base;
 					x = 0;
 
+					igt_assert(base);
+
 					for (i = 0; i < size/sizeof(*ptr); i++)
 						x += ptr[i];
 
@@ -126,6 +130,8 @@ int main(int argc, char **argv)
 					base = gem_mmap__cpu(fd, handle, 0, size, PROT_READ | PROT_WRITE);
 					ptr = base;
 
+					igt_assert(base);
+
 					for (i = 0; i < size/sizeof(*ptr); i++)
 						ptr[i] = i;
 
@@ -138,6 +144,7 @@ int main(int argc, char **argv)
 				gettimeofday(&start, NULL);
 				for (loop = 0; loop < 1000; loop++) {
 					base = gem_mmap__cpu(fd, handle, 0, size, PROT_READ | PROT_WRITE);
+					igt_assert(base);
 					memset(base, 0, size);
 					munmap(base, size);
 				}
@@ -147,6 +154,7 @@ int main(int argc, char **argv)
 
 				gettimeofday(&start, NULL);
 				base = gem_mmap__cpu(fd, handle, 0, size, PROT_READ | PROT_WRITE);
+				igt_assert(base);
 				for (loop = 0; loop < 1000; loop++)
 					memset(base, 0, size);
 				munmap(base, size);
@@ -178,6 +186,8 @@ int main(int argc, char **argv)
 			volatile uint32_t *ptr = base;
 			int x = 0;
 
+			igt_assert(base);
+
 			for (i = 0; i < size/sizeof(*ptr); i++)
 				x += ptr[i];
 
@@ -193,6 +203,8 @@ int main(int argc, char **argv)
 			volatile uint32_t *ptr = base;
 			int x = 0;
 
+			igt_assert(base);
+
 			for (i = 0; i < size/sizeof(*ptr); i++)
 				x += ptr[i];
 
@@ -212,6 +224,8 @@ int main(int argc, char **argv)
 				volatile uint32_t *ptr = base;
 				int x = 0;
 
+				igt_assert(base);
+
 				for (i = 0; i < size/sizeof(*ptr); i++)
 					x += ptr[i];
 
@@ -232,6 +246,8 @@ int main(int argc, char **argv)
 			uint32_t *base = gem_mmap__gtt(fd, handle, size, PROT_READ | PROT_WRITE);
 			volatile uint32_t *ptr = base;
 
+			igt_assert(base);
+
 			for (i = 0; i < size/sizeof(*ptr); i++)
 				ptr[i] = i;
 
@@ -248,6 +264,8 @@ int main(int argc, char **argv)
 				uint32_t *base = gem_mmap__wc(fd, handle, 0, size, PROT_READ | PROT_WRITE);
 				volatile uint32_t *ptr = base;
 
+				igt_assert(base);
+
 				for (i = 0; i < size/sizeof(*ptr); i++)
 					ptr[i] = i;
 
diff --git a/tests/gem_largeobject.c b/tests/gem_largeobject.c
index 2f0ec93..d261939 100644
--- a/tests/gem_largeobject.c
+++ b/tests/gem_largeobject.c
@@ -65,6 +65,7 @@ test_large_object(int fd)
 
 	/* prefault */
 	ptr = gem_mmap__gtt(fd, create.handle, obj_size, PROT_WRITE | PROT_READ);
+	igt_assert(ptr);
 	*ptr = 0;
 
 	gem_write(fd, create.handle, 0, data, obj_size);
diff --git a/tests/gem_mmap.c b/tests/gem_mmap.c
index 49e7259..4188429 100644
--- a/tests/gem_mmap.c
+++ b/tests/gem_mmap.c
@@ -167,6 +167,7 @@ igt_main
 		igt_assert(OBJECT_SIZE > 4096);
 		arg.handle = gem_create(fd, OBJECT_SIZE);
 		addr = gem_mmap__cpu(fd, arg.handle, 0, 4096, PROT_WRITE);
+		igt_assert(addr);
 		memset(addr, 0, 4096);
 		munmap(addr, 4096);
 		gem_close(fd, arg.handle);
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index ef8890e..1e8f5be 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -113,7 +113,9 @@ static void as_gtt_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
 	BUILD_EXEC;
 
 	src_ptr = gem_mmap__gtt(fd, src, OBJECT_SIZE, PROT_WRITE);
+	igt_assert(src_ptr);
 	dst_ptr = gem_mmap__gtt(fd, dst, OBJECT_SIZE, PROT_READ);
+	igt_assert(dst_ptr);
 
 	while (loops--) {
 		gem_set_domain(fd, src,
@@ -138,7 +140,9 @@ static void as_cpu_mmap(int fd, uint32_t src, uint32_t dst, void *buf, int len,
 	BUILD_EXEC;
 
 	src_ptr = gem_mmap__cpu(fd, src, 0, OBJECT_SIZE, PROT_WRITE);
+	igt_assert(src_ptr);
 	dst_ptr = gem_mmap__cpu(fd, dst, 0, OBJECT_SIZE, PROT_READ);
+	igt_assert(dst_ptr);
 
 	while (loops--) {
 		gem_set_domain(fd, src,
@@ -183,7 +187,9 @@ static void test_as_gtt_mmap(int fd, uint32_t src, uint32_t dst, int len)
 	BUILD_EXEC;
 
 	src_ptr = gem_mmap__gtt(fd, src, OBJECT_SIZE, PROT_WRITE);
+	igt_assert(src_ptr);
 	dst_ptr = gem_mmap__gtt(fd, dst, OBJECT_SIZE, PROT_READ);
+	igt_assert(dst_ptr);
 
 	gem_set_domain(fd, src, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 	for (i = 0; i < len/4; i++)
@@ -207,7 +213,9 @@ static void test_as_cpu_mmap(int fd, uint32_t src, uint32_t dst, int len)
 	BUILD_EXEC;
 
 	src_ptr = gem_mmap__cpu(fd, src, 0, OBJECT_SIZE, PROT_WRITE);
+	igt_assert(src_ptr);
 	dst_ptr = gem_mmap__cpu(fd, dst, 0, OBJECT_SIZE, PROT_READ);
+	igt_assert(dst_ptr);
 
 	gem_set_domain(fd, src, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
 	for (i = 0; i < len/4; i++)
diff --git a/tests/gem_streaming_writes.c b/tests/gem_streaming_writes.c
index 39cb88d..3f7ed95 100644
--- a/tests/gem_streaming_writes.c
+++ b/tests/gem_streaming_writes.c
@@ -89,15 +89,17 @@ static void test_streaming(int fd, int mode, int sync)
 	case 0: /* cpu/snoop */
 		gem_set_caching(fd, src, I915_CACHING_CACHED);
 		s = gem_mmap__cpu(fd, src, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+		igt_assert(s);
 		break;
 	case 1: /* gtt */
 		s = gem_mmap__gtt(fd, src, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+		igt_assert(s);
 		break;
 	case 2: /* wc */
 		s = gem_mmap__wc(fd, src, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+		igt_assert(s);
 		break;
 	}
-	igt_assert(s);
 	*s = 0; /* fault the object into the mappable range first (for GTT) */
 
 	d = gem_mmap__cpu(fd, dst, 0, OBJECT_SIZE, PROT_READ);
@@ -284,15 +286,17 @@ static void test_batch(int fd, int mode, int reverse)
 	case 0: /* cpu/snoop */
 		igt_require(gem_has_llc(fd));
 		base = gem_mmap__cpu(fd, exec[BATCH].handle, 0, batch_size, PROT_READ | PROT_WRITE);
+		igt_assert(base);
 		break;
 	case 1: /* gtt */
 		base = gem_mmap__gtt(fd, exec[BATCH].handle, batch_size, PROT_READ | PROT_WRITE);
+		igt_assert(base);
 		break;
 	case 2: /* wc */
 		base = gem_mmap__wc(fd, exec[BATCH].handle, 0, batch_size, PROT_READ | PROT_WRITE);
+		igt_assert(base);
 		break;
 	}
-	igt_assert(base);
 	*base = 0; /* fault the object into the mappable range first */
 
 	gem_write(fd, exec[BATCH].handle, 0, tmp, sizeof(tmp));
diff --git a/tests/gem_tiled_pread_basic.c b/tests/gem_tiled_pread_basic.c
index 407808b..e1844b0 100644
--- a/tests/gem_tiled_pread_basic.c
+++ b/tests/gem_tiled_pread_basic.c
@@ -73,6 +73,7 @@ create_bo(int fd)
 
 	/* Fill the BO with dwords starting at start_val */
 	data = gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
+	igt_assert(data);
 	for (i = 0; i < WIDTH*HEIGHT; i++)
 		data[i] = i;
 	munmap(data, sizeof(linear));
diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c
index c952ce7..6e048db 100644
--- a/tests/gem_tiled_pread_pwrite.c
+++ b/tests/gem_tiled_pread_pwrite.c
@@ -80,6 +80,7 @@ create_bo_and_fill(int fd)
 
 	/* Fill the BO with dwords starting at start_val */
 	data = gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
+	igt_assert(data);
 	for (i = 0; i < WIDTH*HEIGHT; i++)
 		data[i] = i;
 	munmap(data, sizeof(linear));
@@ -123,6 +124,7 @@ igt_simple_main
 
 		/* Check the target bo's contents. */
 		data = gem_mmap__gtt(fd, handle_target, sizeof(linear), PROT_READ | PROT_WRITE);
+		igt_assert(data);
 		for (j = 0; j < WIDTH*HEIGHT; j++)
 			igt_assert_f(data[j] == j,
 				     "mismatch at %i: %i\n",
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c
index b50fa7f..a66523b 100644
--- a/tests/gem_tiled_swapping.c
+++ b/tests/gem_tiled_swapping.c
@@ -110,6 +110,7 @@ check_bo(int fd, uint32_t handle)
 	int j;
 
 	data = gem_mmap__gtt(fd, handle, LINEAR_DWORDS, PROT_READ);
+	igt_assert(data);
 	gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
 	j = rand() % (WIDTH * HEIGHT);
 	igt_assert_f(data[j] == j, "mismatch at %i: %i\n", j, data[j]);
diff --git a/tests/gem_tiled_wb.c b/tests/gem_tiled_wb.c
index f52588d..654628e 100644
--- a/tests/gem_tiled_wb.c
+++ b/tests/gem_tiled_wb.c
@@ -72,6 +72,7 @@ create_bo(int fd)
 	 * We then manually detile on reading back through the mmap(wc).
 	 */
 	data = gem_mmap__gtt(fd, handle, SIZE, PROT_READ | PROT_WRITE);
+	igt_assert(data);
 	for (i = 0; i < WIDTH*HEIGHT; i++)
 		data[i] = i;
 	munmap(data, SIZE);
diff --git a/tests/gem_tiled_wc.c b/tests/gem_tiled_wc.c
index 0f74223..3eee796 100644
--- a/tests/gem_tiled_wc.c
+++ b/tests/gem_tiled_wc.c
@@ -66,6 +66,7 @@ create_bo(int fd)
 
 	/* Fill the BO with dwords starting at start_val */
 	data = gem_mmap__gtt(fd, handle, SIZE, PROT_READ | PROT_WRITE);
+	igt_assert(data);
 	for (i = 0; i < WIDTH*HEIGHT; i++)
 		data[i] = i;
 	munmap(data, SIZE);
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
index 6fff3a9..e6830f6 100644
--- a/tests/gem_userptr_blits.c
+++ b/tests/gem_userptr_blits.c
@@ -689,10 +689,12 @@ static void *umap(int fd, uint32_t handle)
 
 	if (gem_has_llc(fd)) {
 		ptr = gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
+		igt_assert(ptr);
 	} else {
 		uint32_t tmp = gem_create(fd, sizeof(linear));
 		copy(fd, tmp, handle, 0);
 		ptr = gem_mmap__cpu(fd, tmp, 0, sizeof(linear), PROT_READ);
+		igt_assert(ptr);
 		gem_close(fd, tmp);
 	}
 
diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c
index dea1e8a..640fb82 100644
--- a/tests/gen7_forcewake_mt.c
+++ b/tests/gen7_forcewake_mt.c
@@ -191,6 +191,7 @@ igt_simple_main
 		gem_sync(t[0].fd, exec[1].handle);
 
 		p = gem_mmap__gtt(t[0].fd, exec[0].handle, 4096, PROT_READ);
+		igt_assert(p);
 
 		igt_info("[%d]={ %08x %08x }\n", i, p[0], p[1]);
 		igt_assert(p[0] & 2);
diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index d580a94..c1af5e6 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -189,6 +189,7 @@ static void fill_mmap_cpu(data_t *data, uint32_t handle, unsigned char color)
 	void *ptr;
 
 	ptr = gem_mmap__cpu(data->drm_fd, handle, 0, 4096, PROT_WRITE);
+	igt_assert(ptr);
 	gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_CPU,
 		       I915_GEM_DOMAIN_CPU);
 	memset(ptr, color, 4);
@@ -201,6 +202,7 @@ static void fill_mmap_gtt(data_t *data, uint32_t handle, unsigned char color)
 	void *ptr;
 
 	ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);
+	igt_assert(ptr);
 	gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_GTT,
 		       I915_GEM_DOMAIN_GTT);
 	memset(ptr, color, 4);
diff --git a/tests/kms_fence_pin_leak.c b/tests/kms_fence_pin_leak.c
index 7d4ffbc..0f5d364 100644
--- a/tests/kms_fence_pin_leak.c
+++ b/tests/kms_fence_pin_leak.c
@@ -90,6 +90,7 @@ static void touch_fences(data_t *data)
 		void *ptr;
 
 		ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		memset(ptr, 0, 4);
 		munmap(ptr, 4096);
diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index 77c92d3..720472f 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -381,6 +381,7 @@ static void run_test(data_t *data)
 	case MMAP_GTT:
 		ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size,
 				    PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(data->drm_fd, handle,
 			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		memset(ptr, 0xcc, data->mod_size);
@@ -390,6 +391,7 @@ static void run_test(data_t *data)
 	case MMAP_GTT_WAITING:
 		ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size,
 				    PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(data->drm_fd, handle,
 			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 
@@ -412,6 +414,7 @@ static void run_test(data_t *data)
 		break;
 	case MMAP_CPU:
 		ptr = gem_mmap__cpu(data->drm_fd, handle, 0, data->mod_size, PROT_WRITE);
+		igt_assert(ptr);
 		gem_set_domain(data->drm_fd, handle,
 			       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
 		memset(ptr, 0, data->mod_size);
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 3364157..026220b 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -972,11 +972,15 @@ static void gem_mmap_subtest(bool gtt_mmap)
 
 	handle = gem_create(drm_fd, buf_size);
 
-	if (gtt_mmap)
+	if (gtt_mmap) {
 		gem_buf = gem_mmap__gtt(drm_fd, handle, buf_size,
 					PROT_READ | PROT_WRITE);
-	else
+		igt_assert(gem_buf);
+	}
+	else {
 		gem_buf = gem_mmap__cpu(drm_fd, handle, 0, buf_size, 0);
+		igt_assert(gem_buf);
+	}
 
 
 	for (i = 0; i < buf_size; i++)
@@ -1007,11 +1011,15 @@ static void gem_mmap_subtest(bool gtt_mmap)
 	 * suspended. */
 	disable_all_screens_and_wait(&ms_data);
 
-	if (gtt_mmap)
+	if (gtt_mmap) {
 		gem_buf = gem_mmap__gtt(drm_fd, handle, buf_size,
 					PROT_READ | PROT_WRITE);
-	else
+		igt_assert(gem_buf);
+	}
+	else {
 		gem_buf = gem_mmap__cpu(drm_fd, handle, 0, buf_size, 0);
+		igt_assert(gem_buf);
+	}
 
 	igt_assert(wait_for_suspended());
 
@@ -1467,6 +1475,7 @@ static void fill_igt_fb(struct igt_fb *fb, uint32_t color)
 	uint32_t *ptr;
 
 	ptr = gem_mmap__gtt(drm_fd, fb->gem_handle, fb->size, PROT_WRITE);
+	igt_assert(ptr);
 	for (i = 0; i < fb->size/sizeof(uint32_t); i++)
 		ptr[i] = color;
 	igt_assert(munmap(ptr, fb->size) == 0);
@@ -1749,6 +1758,7 @@ static void fences_subtest(bool dpms)
 
 	buf_ptr = gem_mmap__gtt(drm_fd, params.fb.gem_handle,
 				params.fb.size, PROT_WRITE | PROT_READ);
+	igt_assert(buf_ptr);
 	for (i = 0; i < params.fb.size/sizeof(uint32_t); i++)
 		buf_ptr[i] = i;
 
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index eb9ab06..582c375 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -61,9 +61,9 @@ check_bo(int fd1, uint32_t handle1, int fd2, uint32_t handle2)
 	int i;
 
 	ptr1 = gem_mmap__gtt(fd1, handle1, BO_SIZE, PROT_READ | PROT_WRITE);
-	ptr2 = gem_mmap__gtt(fd2, handle2, BO_SIZE, PROT_READ | PROT_WRITE);
-
 	igt_assert(ptr1);
+	ptr2 = gem_mmap__gtt(fd2, handle2, BO_SIZE, PROT_READ | PROT_WRITE);
+	igt_assert(ptr2);
 
 	/* check whether it's still our old object first. */
 	for (i = 0; i < BO_SIZE; i++) {
-- 
2.4.9

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux