From 5eb316d77cb178d671d67a5451db0a2ca52269ff Mon Sep 17 00:00:00 2001 From: xufeng wang <550002860@gehealthcare.com> Date: Fri, 11 Apr 2025 13:41:37 +0800 Subject: [PATCH] libweston: fix crash when getting connector's property failed When weston tries to update drm head info, if the connector is disconnected, it cannot get the connector's property. If get connector's property failed, drm_connector_assign_connector_info returns -1 and head->connector->conn, head->connector->props_drm remain to be nullptr, but they are used in update_head_from_connector, so the crash occurs. So just return ret when drm_connector_assign_connector_info returns -1, and head->connector, head->connector will not be used later. Signed-off-by: xufeng wang <550002860@gehealthcare.com> --- libweston/backend-drm/drm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 0865b2cd0..fb15cac27 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -2836,10 +2836,11 @@ drm_head_update_info(struct drm_head *head, drmModeConnector *conn) int ret; ret = drm_connector_assign_connector_info(&head->connector, conn); - - update_head_from_connector(head); - weston_head_set_content_protection_status(&head->base, - drm_head_get_current_protection(head)); + if (ret == 0) { + update_head_from_connector(head); + weston_head_set_content_protection_status(&head->base, + drm_head_get_current_protection(head)); + } return ret; }