From 605b50fcd9fe578388fa058e33650c837e1cfca5 Mon Sep 17 00:00:00 2001 From: antonino Date: Mon, 22 Aug 2022 17:49:49 +0200 Subject: [PATCH] kmsdrm: added missing checks --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 4782f5b36..7f88960ea 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -557,24 +557,23 @@ KMSDRM_CrtcGetPropId(uint32_t drm_fd, return prop_id; } -static uint32_t KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id) { +static bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) { drmModeObjectPropertiesPtr drm_props; - uint32_t vrr_prop_id; drm_props = KMSDRM_drmModeObjectGetProperties(drm_fd, crtc_id, DRM_MODE_OBJECT_CRTC); if (!drm_props) - exit(-1); + return false; - vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd, + *vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd, drm_props, "VRR_ENABLED"); KMSDRM_drmModeFreeObjectProperties(drm_props); - return vrr_prop_id; + return true; } static SDL_bool @@ -591,6 +590,9 @@ KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, output_id, DRM_MODE_OBJECT_CONNECTOR); + if(!props) + return SDL_FALSE; + for (i = 0; !found && i < props->count_props; ++i) { drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); @@ -613,7 +615,9 @@ KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, void KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled) { - uint32_t vrr_prop_id = KMSDRM_VrrPropId(drm_fd, crtc_id); + uint32_t vrr_prop_id; + if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id)) + return; KMSDRM_drmModeObjectSetProperty(drm_fd, crtc_id,