diff options
author | Ben Widawsky <ben@bwidawsk.net> | 2016-11-05 14:46:04 -0700 |
---|---|---|
committer | Ben Widawsky <ben@bwidawsk.net> | 2017-04-13 11:19:08 -0700 |
commit | 79f341579c64b380e05b6b22b18fe32625a86303 (patch) | |
tree | 598fd71d75fffbde6f4adbae13d4b960af0a33cc | |
parent | ad3855b4605e781def437eb790f4dd350f2a5be2 (diff) |
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).
-rw-r--r-- | drm-atomic.c | 9 | ||||
-rw-r--r-- | drm-legacy.c | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/drm-atomic.c b/drm-atomic.c index 27c6b1e..c06e52f 100644 --- a/drm-atomic.c +++ b/drm-atomic.c @@ -187,6 +187,11 @@ static int atomic_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) { + printf("Failed to get a new framebuffer BO\n"); + return -1; + } + drm.kms_in_fence_fd = -1; @@ -235,6 +240,10 @@ static int atomic_run(const struct gbm *gbm, const struct egl *egl) next_bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(next_bo); + if (!fb) { + printf("Failed to get a new framebuffer BO\n"); + return -1; + } /* * Here you could also update drm plane layers if you want 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 |