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: Imre Deak <imre.deak@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200226203455.23032-2-imre.deak@intel.com
This commit is contained in:
parent
7a9ccdd1e0
commit
b48f4b3be9
@ -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+ */
|
||||
|
Loading…
Reference in New Issue
Block a user