backend-drm: Cleanup output's disable head list when destroying it

Avoid memory use-after-free when the trying to remove entries from an
already freed list later.

Also add missing removal in drm_output_detach_head() and drm_head_destroy().

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
This commit is contained in:
Jeffy Chen 2024-02-21 09:30:56 +08:00 committed by Pekka Paalanen
parent 1db0da8c8d
commit 9406664a54
1 changed files with 5 additions and 0 deletions

View File

@ -1686,6 +1686,7 @@ drm_output_detach_head(struct weston_output *output_base,
return;
/* Drop connectors that should no longer be driven on next repaint. */
wl_list_remove(&head->disable_head_link);
wl_list_insert(&output->disable_head, &head->disable_head_link);
}
@ -2381,6 +2382,8 @@ drm_output_destroy(struct weston_output *base)
assert(output->hdr_output_metadata_blob_id == 0);
wl_list_remove(&output->disable_head);
free(output);
}
@ -2704,6 +2707,8 @@ drm_head_destroy(struct weston_head *base)
if (head->backlight)
backlight_destroy(head->backlight);
wl_list_remove(&head->disable_head_link);
free(head->display_data);
free(head);
}