From e62de1c7c4ecde0bea5256faec0e8793810f9410 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Fri, 2 Feb 2018 10:58:42 +0100 Subject: lib/igt_fb: Make igt_remove_fb more robust This will make it easier for tests to unconditionally call igt_remove_fb, without first checking whether the FB is allocated. Signed-off-by: Maarten Lankhorst Reviewed-by: Mika Kahola Tested-by: Vidya Srinivas --- lib/igt_fb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/igt_fb.c') diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 6fecdd66..35a928b9 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1623,9 +1623,13 @@ void igt_put_cairo_ctx(int fd, struct igt_fb *fb, cairo_t *cr) */ void igt_remove_fb(int fd, struct igt_fb *fb) { + if (!fb || !fb->fb_id) + return; + cairo_surface_destroy(fb->cairo_surface); do_or_die(drmModeRmFB(fd, fb->fb_id)); gem_close(fd, fb->gem_handle); + fb->fb_id = 0; } /** -- cgit v1.2.3