--- a/sys/dev/drm/amd/display/dc/core/dc.c +++ b/sys/dev/drm/amd/display/dc/core/dc.c @@ -518,12 +518,21 @@ static void destruct(struct dc *dc) { - dc_release_state(dc->current_state); - dc->current_state = NULL; + /* + * construct() jumps here on any allocation failure, so nothing + * beyond the kzalloc'd dc may be assumed to exist yet. + */ + if (dc->current_state) { + dc_release_state(dc->current_state); + dc->current_state = NULL; + } destroy_links(dc); dc_destroy_resource_pool(dc); + + if (dc->ctx == NULL) + return; if (dc->ctx->gpio_service) dal_gpio_service_destroy(&dc->ctx->gpio_service);