summaryrefslogtreecommitdiff
path: root/lib/igt_fb.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-02-02 10:58:42 +0100
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-02-12 13:12:56 +0100
commite62de1c7c4ecde0bea5256faec0e8793810f9410 (patch)
tree9212db7ee25d290b418a05f38bf5685f264c0244 /lib/igt_fb.c
parent1cbec8b8cfd7550d4b1bdd72529a87faf5f6e736 (diff)
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 <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
Diffstat (limited to 'lib/igt_fb.c')
-rw-r--r--lib/igt_fb.c4
1 files changed, 4 insertions, 0 deletions
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;
}
/**