Commit b48f4b3b authored by Imre Deak's avatar Imre Deak

drm/i915: Fix bounds check in intel_get_shared_dpll_id()

Fix an off-by-one error in the upper-bound check and while at it clear
up a bit the function.
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200226203455.23032-2-imre.deak@intel.com
parent 7a9ccdd1
......@@ -103,11 +103,14 @@ enum intel_dpll_id
intel_get_shared_dpll_id(struct drm_i915_private *dev_priv,
struct intel_shared_dpll *pll)
{
if (drm_WARN_ON(&dev_priv->drm, pll < dev_priv->shared_dplls ||
pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll]))
long pll_idx = pll - dev_priv->shared_dplls;
if (drm_WARN_ON(&dev_priv->drm,
pll_idx < 0 ||
pll_idx >= dev_priv->num_shared_dpll))
return -1;
return (enum intel_dpll_id) (pll - dev_priv->shared_dplls);
return pll_idx;
}
/* For ILK+ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment