kms: HACK: avoid crashing on bad edids

This commit is contained in:
Victoria Brekenfeld 2024-07-17 14:53:22 +02:00 committed by Victoria Brekenfeld
parent 0a97147e45
commit 4a22724cb8

View file

@ -9,7 +9,11 @@ use smithay::reexports::drm::control::{
property, AtomicCommitFlags, Device as ControlDevice, Mode, ModeFlags, PlaneType,
ResourceHandle,
};
use std::{collections::HashMap, ops::Range};
use std::{
collections::HashMap,
ops::Range,
panic::{catch_unwind, AssertUnwindSafe},
};
pub fn display_configuration(
device: &mut impl ControlDevice,
@ -183,7 +187,11 @@ pub fn edid_info(device: &impl ControlDevice, connector: connector::Handle) -> R
if let property::Value::Blob(edid_blob) = edid_info.value_type().convert_value(val) {
let blob = device.get_property_blob(edid_blob)?;
let mut reader = std::io::Cursor::new(blob);
if let Some(edid) = edid_parse(&mut reader).ok() {
if let Some(edid) =
catch_unwind(AssertUnwindSafe(move || edid_parse(&mut reader).ok()))
.ok()
.flatten()
{
manufacturer = {
let id = edid.product.manufacturer_id;
let code = [id.0, id.1, id.2];