All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Harish Chegondi <harish.chegondi@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm()
Date: Fri, 17 Dec 2021 12:18:15 +0200	[thread overview]
Message-ID: <874k77357c.fsf@intel.com> (raw)
In-Reply-To: <20211216232124.1298010-1-harish.chegondi@intel.com>

On Thu, 16 Dec 2021, Harish Chegondi <harish.chegondi@intel.com> wrote:
> Check return pointer from intel_crtc_for_plane() before dereferencing
> it, as it can be NULL.

If you're doing this to satisfy some static analyzer, in these cases the
code would read *much* better if you added the NULL check inside
intel_crtc_active().

BR,
Jani.


>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Caz Yokoyama <caz.yokoyama@intel.com>
> Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> Signed-off-by: Harish Chegondi <harish.chegondi@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index bdf97a8c9ef3..c7a4d8d971d7 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -2373,7 +2373,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv)
>  	else
>  		fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_A);
>  	crtc = intel_crtc_for_plane(dev_priv, PLANE_A);
> -	if (intel_crtc_active(crtc)) {
> +	if (crtc && intel_crtc_active(crtc)) {
>  		const struct drm_display_mode *pipe_mode =
>  			&crtc->config->hw.pipe_mode;
>  		const struct drm_framebuffer *fb =
> @@ -2403,7 +2403,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv)
>  	else
>  		fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_B);
>  	crtc = intel_crtc_for_plane(dev_priv, PLANE_B);
> -	if (intel_crtc_active(crtc)) {
> +	if (crtc && intel_crtc_active(crtc)) {
>  		const struct drm_display_mode *pipe_mode =
>  			&crtc->config->hw.pipe_mode;
>  		const struct drm_framebuffer *fb =

-- 
Jani Nikula, Intel Open Source Graphics Center

      parent reply	other threads:[~2021-12-17 10:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 23:21 [Intel-gfx] [PATCH] drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm() Harish Chegondi
2021-12-17  9:50 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
2021-12-17 10:18 ` Jani Nikula [this message]

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=874k77357c.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=harish.chegondi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.