Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Limit the for_each_set_bit() to the valid range
Date: Thu, 17 Jan 2019 17:07:53 +0200	[thread overview]
Message-ID: <20190117150753.GE20097@intel.com> (raw)
In-Reply-To: <20190116155421.7660-1-chris@chris-wilson.co.uk>

On Wed, Jan 16, 2019 at 03:54:21PM +0000, Chris Wilson wrote:
> Let static analyzers (smatch) know that we are not going to wander off
> the end of the array by providing a tight upper bound:
> 
> drivers/gpu/drm/i915/intel_display.c:9532 hsw_get_transcoder_state() error: buffer overflow 'dev_priv->__info.trans_offsets' 6 <= 31
> 
> References: 0716931a82b4 ("drm/i915/icl: fix transcoder state readout")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Madhav Chauhan <madhav.chauhan@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 62d61fcad89c..b087ed285cc1 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -9526,7 +9526,9 @@ static bool hsw_get_transcoder_state(struct intel_crtc *crtc,
>  	 * XXX: Do intel_display_power_get_if_enabled before reading this (for
>  	 * consistency and less surprising code; it's in always on power).
>  	 */
> -	for_each_set_bit(panel_transcoder, &panel_transcoder_mask, 32) {
> +	for_each_set_bit(panel_transcoder,
> +			 &panel_transcoder_mask,
> +			 ARRAY_SIZE(INTEL_INFO(dev_priv)->trans_offsets)) {

Or just I915_MAX_TRANSCODERS maybe? Doesn't really matter I suppose.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  		enum pipe trans_pipe;
>  
>  		tmp = I915_READ(TRANS_DDI_FUNC_CTL(panel_transcoder));
> -- 
> 2.20.1

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-01-17 15:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 15:54 [PATCH] drm/i915: Limit the for_each_set_bit() to the valid range Chris Wilson
2019-01-17  8:34 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2019-01-17  8:52 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-17 12:36 ` ✓ Fi.CI.IGT: " Patchwork
2019-01-17 15:07 ` Ville Syrjälä [this message]
2019-01-17 15:13   ` [PATCH] " Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190117150753.GE20097@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox