Skip to content

Commit 24a644e

Browse files
committed
drm/i915/opregion: check port number bounds for SWSCI display power state
The mapping from enum port to whatever port numbering scheme is used by the SWSCI Display Power State Notification is odd, and the memory of it has faded. In any case, the parameter only has space for ports numbered [0..4], and UBSAN reports bit shift beyond it when the platform has port F or more. Since the SWSCI functionality is supposed to be obsolete for new platforms (i.e. ones that might have port F or more), just bail out early if the mapped and mangled port number is beyond what the Display Power State Notification can support. Fixes: 9c4b0a6 ("drm/i915: add opregion function to notify bios of encoder enable/disable") Cc: <stable@vger.kernel.org> # v3.13+ Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4800 Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/cc363f42d6b5a5932b6d218fefcc8bdfb15dbbe5.1644489329.git.jani.nikula@intel.com
1 parent 24524e3 commit 24a644e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎drivers/gpu/drm/i915/display/intel_opregion.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,21 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
363363
port++;
364364
}
365365

366+
/*
367+
* The port numbering and mapping here is bizarre. The now-obsolete
368+
* swsci spec supports ports numbered [0..4]. Port E is handled as a
369+
* special case, but port F and beyond are not. The functionality is
370+
* supposed to be obsolete for new platforms. Just bail out if the port
371+
* number is out of bounds after mapping.
372+
*/
373+
if (port > 4) {
374+
drm_dbg_kms(&dev_priv->drm,
375+
"[ENCODER:%d:%s] port %c (index %u) out of bounds for display power state notification\n",
376+
intel_encoder->base.base.id, intel_encoder->base.name,
377+
port_name(intel_encoder->port), port);
378+
return -EINVAL;
379+
}
380+
366381
if (!enable)
367382
parm |= 4 << 8;
368383

0 commit comments

Comments
 (0)