https://github.com/eyelash/tutorials/blob/30aaec4a896e90f6bda28ef1c99c9604731979b6/drm-gbm.c#L47 See http://manpages.ubuntu.com/manpages/xenial/man3/drmModeGetResources.3.html - function may return NULL, at which point a segfault will happen a few lines later.