[Intel-gfx] [PATCH i-g-t] lib: Make sure we don't use a negative offset

Tomeu Vizoso tomeu.vizoso at collabora.com
Fri Jan 6 14:03:20 UTC 2017


As bytes_read can contain an error condition under some circumstances,
in which we want to error out.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
---
 lib/igt_debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index d828687a62ca..b1b67e740041 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -601,6 +601,7 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 		igt_assert(pipe_crc->flags & O_NONBLOCK);
 		bytes_read = 0;
 	}
+	igt_assert_lte(0, bytes_read);
 	buf[bytes_read] = '\0';
 
 	if (bytes_read && !pipe_crc_init_from_string(pipe_crc, out, buf))
-- 
2.9.3



More information about the Intel-gfx mailing list