[igt-dev] [PATCH v2 8/8] tests/fbdev: Add tests for read/writing with NULL-pointer buffers

Thomas Zimmermann tzimmermann at suse.de
Fri Nov 6 08:29:55 UTC 2020


Trying to read and write with a NULL-pointer buffer should fail and
report EFAULT.

Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
 tests/fbdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/fbdev.c b/tests/fbdev.c
index 5b7086d1..6e279415 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -235,6 +235,18 @@ static void framebuffer_tests(int fd)
 		igt_require_f(ret == 0, "read at EOF, ret=%zd\n", ret);
 	}
 
+	igt_subtest("nullptr") {
+		ssize_t ret;
+
+		igt_describe("Check framebuffer access with NULL");
+
+		ret = pread(fd, NULL, fix_info.smem_len, 0);
+		igt_require_f((ret == -1) && (errno == EFAULT), "reading into NULL did not return EFAULT, ret=%zd\n", ret);
+
+		ret = pwrite(fd, NULL, fix_info.smem_len, 0);
+		igt_require_f((ret == -1) && (errno == EFAULT), "writing from NULL did not return EFAULT, ret=%zd\n", ret);
+	}
+
 	igt_fixture {
 		free(buf);
 		memset(map, 0, fix_info.smem_len); // don't leave garbage on the screen
-- 
2.29.0



More information about the igt-dev mailing list