From 4e4d79d4cae92c5ec29882cea9b8f7e8355f1232 Mon Sep 17 00:00:00 2001 From: Joonyoung Shim Date: Mon, 13 Apr 2015 17:32:14 +0900 Subject: modetest: fix Segmentation fault If use -P option without -s option, the program segfaults due to dev.mode.bo being NULL. Signed-off-by: Joonyoung Shim [Emil Velikov: Tweak the commit message.] Reviewed-by: Emil Velikov --- tests/modetest/modetest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/modetest') diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index e646790b..966c2b66 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -1119,6 +1119,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; @@ -1642,7 +1648,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); -- cgit v1.2.3