Commit cbe80d47080f7e5b11d952e0978f9ca3b4bbb480

Sylvain Becker 2019-03-13T14:54:51

KMSDRM: valid file descriptors could positive or 0. -1 is invalid. (Bug 4530)

diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index eebd7e8..8562d35 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -250,7 +250,7 @@ KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data)
 {
     KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)data;
 
-    if (fb_info && fb_info->drm_fd > 0 && fb_info->fb_id != 0) {
+    if (fb_info && fb_info->drm_fd >= 0 && fb_info->fb_id != 0) {
         KMSDRM_drmModeRmFB(fb_info->drm_fd, fb_info->fb_id);
         SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Delete DRM FB %u", fb_info->fb_id);
     }
@@ -552,7 +552,7 @@ KMSDRM_VideoQuit(_THIS)
     }
 
     if(vdata->saved_crtc != NULL) {
-        if(vdata->drm_fd > 0 && vdata->saved_conn_id > 0) {
+        if(vdata->drm_fd >= 0 && vdata->saved_conn_id > 0) {
             /* Restore saved CRTC settings */
             drmModeCrtc *crtc = vdata->saved_crtc;
             if(KMSDRM_drmModeSetCrtc(vdata->drm_fd, crtc->crtc_id, crtc->buffer_id,