From 2e7e0e6549dab5fd057677d09ccf0c05a92a4bf9 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 24 Feb 2022 12:59:55 +0000 Subject: [PATCH] drm/i915/opregion: check port number bounds for SWSCI display power state From Jani Nikula d006f2fe7d627b3ff3f637cf2fa90d30e05887c9 in linux 5.15.y/5.15.25 ea958422291de248b9e2eaaeea36004e84b64043 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 abbe6e852bd..df469af1667 100644 --- a/sys/dev/pci/drm/i915/display/intel_opregion.c +++ b/sys/dev/pci/drm/i915/display/intel_opregion.c @@ -361,6 +361,21 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, port++; } + /* + * 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