From 6b082cca5fd2b0194ecd12140f7fa51838f9ab8d Mon Sep 17 00:00:00 2001 From: Ben Widawsky Date: Sat, 5 Nov 2016 14:46:04 -0700 Subject: drm: Provide a failure path when getting the fb This is helpful for debugging as you will bail early with an error message instead of a random SIGSEGV (or something more obscure). Signed-off-by: Ben Widawsky Reviewed-by: Emil Velikov --- drm-legacy.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drm-legacy.c') diff --git a/drm-legacy.c b/drm-legacy.c index 3b407f8..a0b419a 100644 --- a/drm-legacy.c +++ b/drm-legacy.c @@ -60,6 +60,10 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) eglSwapBuffers(egl->display, egl->surface); bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(bo); + if (!fb) { + fprintf(stderr, "Failed to get a new framebuffer BO\n"); + return -1; + } /* set mode: */ ret = drmModeSetCrtc(drm.fd, drm.crtc_id, fb->fb_id, 0, 0, @@ -78,6 +82,10 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) eglSwapBuffers(egl->display, egl->surface); next_bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(next_bo); + if (!fb) { + fprintf(stderr, "Failed to get a new framebuffer BO\n"); + return -1; + } /* * Here you could also update drm plane layers if you want -- cgit v1.2.1