[PATCH libdrm 1/5] modetest: fix Segmentation fault

Joonyoung Shim jy0922.shim at samsung.com
Mon Apr 13 01:32:14 PDT 2015


If use -P option without -s option, we meet Segmentation fault error
when modetest is terminated. Check whether dev.mode.bo is NULL.

Signed-off-by: Joonyoung Shim <jy0922.shim at samsung.com>
---
 tests/modetest/modetest.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 5f46efd..b59f6b5 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1113,6 +1113,12 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
 	dev->mode.fb_id = fb_id;
 }
 
+static void clear_mode(struct device *dev)
+{
+	if (dev->mode.bo)
+		bo_destroy(dev->mode.bo);
+}
+
 static void set_planes(struct device *dev, struct plane_arg *p, unsigned int count)
 {
 	unsigned int i;
@@ -1636,7 +1642,8 @@ int main(int argc, char **argv)
 		if (test_cursor)
 			clear_cursors(&dev);
 
-		bo_destroy(dev.mode.bo);
+		if (count)
+			clear_mode(&dev);
 	}
 
 	free_resources(dev.resources);
-- 
1.9.1



More information about the dri-devel mailing list