From d74782de5168a33a5a6f230df80aca8916835c7c Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 11 Apr 2022 03:36:37 +0000 Subject: [PATCH] drm/i915/opregion: check port number bounds for SWSCI From Jani Nikula d8b8bd1d03ee7db8e7cb79748a70c2eef4dd706f in linux 5.15.y/5.15.33 24a644ebbfd3b13cda702f98907f9dd123e34bf9 in mainline linux --- sys/dev/pci/drm/i915/display/intel_opregion.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/dev/pci/drm/i915/display/intel_opregion.c b/sys/dev/pci/drm/i915/display/intel_opregion.c index df469af1667..610a1e40d81 100644 --- a/sys/dev/pci/drm/i915/display/intel_opregion.c +++ b/sys/dev/pci/drm/i915/display/intel_opregion.c @@ -376,6 +376,21 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, return -EINVAL; } + /* + * The port numbering and mapping here is bizarre. The now-obsolete + * swsci spec supports ports numbered [0..4]. Port E is handled as a + * special case, but port F and beyond are not. The functionality is + * supposed to be obsolete for new platforms. Just bail out if the port + * number is out of bounds after mapping. + */ + if (port > 4) { + drm_dbg_kms(&dev_priv->drm, + "[ENCODER:%d:%s] port %c (index %u) out of bounds for display power state notification\n", + intel_encoder->base.base.id, intel_encoder->base.name, + port_name(intel_encoder->port), port); + return -EINVAL; + } + if (!enable) parm |= 4 << 8; -- 2.20.1