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>
This commit is contained in:
xufeng wang 2025-04-11 13:41:37 +08:00
parent 8762c3bab5
commit 5eb316d77c

View file

@ -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;
}