Re: [PATCH 2/5] drm/i915/dpll: replace BUG_ON() with drm_WARN_ON()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 26, 2022 at 11:38:14AM +0300, Jani Nikula wrote:
> Avoid BUG_ON(). Actually check the dpll count and bail out loudly with
> drm_WARN_ON() from the loop before overflowing
> i915->dpll.shared_dplls[].
> 
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
> index 118598c9a809..8dd405553cfa 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
> +++ b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
> @@ -4199,6 +4199,10 @@ void intel_shared_dpll_init(struct drm_i915_private *dev_priv)
>  	dpll_info = dpll_mgr->dpll_info;
>  
>  	for (i = 0; dpll_info[i].name; i++) {
> +		if (drm_WARN_ON(&dev_priv->drm,
> +				i >= ARRAY_SIZE(dev_priv->dpll.shared_dplls)))
> +			break;

Shame we can't neatly use a BUILD_BUG_ON() when assigning .dpll_info.

For patches 2-5
Reviewed-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

> +
>  		drm_WARN_ON(&dev_priv->drm, i != dpll_info[i].id);
>  		dev_priv->dpll.shared_dplls[i].info = &dpll_info[i];
>  	}
> @@ -4206,8 +4210,6 @@ void intel_shared_dpll_init(struct drm_i915_private *dev_priv)
>  	dev_priv->dpll.mgr = dpll_mgr;
>  	dev_priv->dpll.num_shared_dpll = i;
>  	mutex_init(&dev_priv->dpll.lock);
> -
> -	BUG_ON(dev_priv->dpll.num_shared_dpll > I915_NUM_PLLS);
>  }
>  
>  /**
> -- 
> 2.34.1

-- 
Ville Syrjälä
Intel



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux