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 <jy0922.shim@samsung.com>
[Emil Velikov: Tweak the commit message.]
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
Joonyoung Shim 2015-04-13 17:32:14 +09:00 committed by Emil Velikov
parent b1d19de764
commit 4e4d79d4ca

View file

@ -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);