All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>,
	David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	VMware Graphics <linux-graphics-maintainer@vmware.com>
Subject: Re: [PATCH] drm/vmwgfx_kms: Fix potential NULL pointer dereference
Date: Tue, 5 Dec 2017 15:30:20 +0200	[thread overview]
Message-ID: <20171205133019.GS10981@intel.com> (raw)
In-Reply-To: <20171204215418.GA23874@embeddedor.com>

On Mon, Dec 04, 2017 at 03:54:18PM -0600, Gustavo A. R. Silva wrote:
> crtc_state is being null checked in a previous code block, which implies
> that such pointer might be null.
> 
> crtc_state is dereferenced in drm_atomic_helper_check_plane_state, hence
> there is a potential null pointer dereference.

This is a false positive. drm_atomic_helper_check_plane_state() will not
dereference crtc_state when plane_state->crtc is NULL.

> 
> Fix this by warning-on and returning -EINVAL in case crtc_state is null.
> 
> Addresses-Coverity-ID: 1462412 ("Dereference after null check")
> Fixes: a01cb8ba3f62 ("drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index a2a93d7..72c3b290 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -454,6 +454,9 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
>  		clip.y2 = crtc_state->adjusted_mode.vdisplay;
>  	}
>  
> +	if (WARN_ON(!crtc_state))
> +		return -EINVAL;

This would in fact break the driver because it would flag an error
whenever the plane is disabled.

> +
>  	ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
>  						  DRM_PLANE_HELPER_NO_SCALING,
>  						  DRM_PLANE_HELPER_NO_SCALING,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>,
	Sinclair Yeh <syeh@vmware.com>,
	Thomas Hellstrom <thellstrom@vmware.com>,
	David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vmwgfx_kms: Fix potential NULL pointer dereference
Date: Tue, 5 Dec 2017 15:30:20 +0200	[thread overview]
Message-ID: <20171205133019.GS10981@intel.com> (raw)
In-Reply-To: <20171204215418.GA23874@embeddedor.com>

On Mon, Dec 04, 2017 at 03:54:18PM -0600, Gustavo A. R. Silva wrote:
> crtc_state is being null checked in a previous code block, which implies
> that such pointer might be null.
> 
> crtc_state is dereferenced in drm_atomic_helper_check_plane_state, hence
> there is a potential null pointer dereference.

This is a false positive. drm_atomic_helper_check_plane_state() will not
dereference crtc_state when plane_state->crtc is NULL.

> 
> Fix this by warning-on and returning -EINVAL in case crtc_state is null.
> 
> Addresses-Coverity-ID: 1462412 ("Dereference after null check")
> Fixes: a01cb8ba3f62 ("drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index a2a93d7..72c3b290 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -454,6 +454,9 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
>  		clip.y2 = crtc_state->adjusted_mode.vdisplay;
>  	}
>  
> +	if (WARN_ON(!crtc_state))
> +		return -EINVAL;

This would in fact break the driver because it would flag an error
whenever the plane is disabled.

> +
>  	ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip,
>  						  DRM_PLANE_HELPER_NO_SCALING,
>  						  DRM_PLANE_HELPER_NO_SCALING,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC

  reply	other threads:[~2017-12-05 13:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-04 21:54 [PATCH] drm/vmwgfx_kms: Fix potential NULL pointer dereference Gustavo A. R. Silva
2017-12-05 13:30 ` Ville Syrjälä [this message]
2017-12-05 13:30   ` Ville Syrjälä
2017-12-05 15:47   ` Gustavo A. R. Silva

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=20171205133019.GS10981@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=garsilva@embeddedor.com \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thellstrom@vmware.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 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.