linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] drm/amd/display: fix dereference of pointer aconnector when it is null
@ 2019-11-08 14:38 Colin King
  2019-11-08 14:42 ` Mikita Lipski
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2019-11-08 14:38 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David Zhou, David Airlie, Daniel Vetter, Lyude Paul,
	Nicholas Kazlauskas, Mikita Lipski, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently pointer aconnector is being dereferenced by the call to
to_dm_connector_state before it is being null checked, this could
lead to a null pointer dereference.  Fix this by checking that
aconnector is null before dereferencing it.

Addresses-Coverity: ("Dereference before null check")
Fixes: 5133c6241d9c ("drm/amd/display: Add MST atomic routines")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index e3cda6984d28..72e677796a48 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -193,12 +193,11 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 	 * that blocks before commit guaranteeing that the state
 	 * is not gonna be swapped while still in use in commit tail */
 
-	dm_conn_state = to_dm_connector_state(aconnector->base.state);
-
-
 	if (!aconnector || !aconnector->mst_port)
 		return false;
 
+	dm_conn_state = to_dm_connector_state(aconnector->base.state);
+
 	mst_mgr = &aconnector->mst_port->mst_mgr;
 
 	if (!mst_mgr->mst_state)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] drm/amd/display: fix dereference of pointer aconnector when it is null
  2019-11-08 14:38 [PATCH][next] drm/amd/display: fix dereference of pointer aconnector when it is null Colin King
@ 2019-11-08 14:42 ` Mikita Lipski
  2019-11-08 16:33   ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Mikita Lipski @ 2019-11-08 14:42 UTC (permalink / raw)
  To: Colin King, Wentland, Harry, Li, Sun peng (Leo),
	Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	David Airlie, Daniel Vetter, Lyude Paul, Kazlauskas, Nicholas,
	Lipski, Mikita, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

Thanks!

Reviewed-by: Mikita Lipski <mikita.lipski@amd.com>

On 08.11.2019 9:38, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently pointer aconnector is being dereferenced by the call to
> to_dm_connector_state before it is being null checked, this could
> lead to a null pointer dereference.  Fix this by checking that
> aconnector is null before dereferencing it.
> 
> Addresses-Coverity: ("Dereference before null check")
> Fixes: 5133c6241d9c ("drm/amd/display: Add MST atomic routines")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index e3cda6984d28..72e677796a48 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -193,12 +193,11 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
>   	 * that blocks before commit guaranteeing that the state
>   	 * is not gonna be swapped while still in use in commit tail */
>   
> -	dm_conn_state = to_dm_connector_state(aconnector->base.state);
> -
> -
>   	if (!aconnector || !aconnector->mst_port)
>   		return false;
>   
> +	dm_conn_state = to_dm_connector_state(aconnector->base.state);
> +
>   	mst_mgr = &aconnector->mst_port->mst_mgr;
>   
>   	if (!mst_mgr->mst_state)
> 

-- 
Thanks,
Mikita Lipski
mikita.lipski@amd.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] drm/amd/display: fix dereference of pointer aconnector when it is null
  2019-11-08 14:42 ` Mikita Lipski
@ 2019-11-08 16:33   ` Alex Deucher
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2019-11-08 16:33 UTC (permalink / raw)
  To: Mikita Lipski
  Cc: Colin King, Wentland, Harry, Li, Sun peng (Leo),
	Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	David Airlie, Daniel Vetter, Lyude Paul, Kazlauskas, Nicholas,
	Lipski, Mikita, amd-gfx, dri-devel, kernel-janitors,
	linux-kernel

Applied.  thanks!

Alex

On Fri, Nov 8, 2019 at 9:42 AM Mikita Lipski <mlipski@amd.com> wrote:
>
> Thanks!
>
> Reviewed-by: Mikita Lipski <mikita.lipski@amd.com>
>
> On 08.11.2019 9:38, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Currently pointer aconnector is being dereferenced by the call to
> > to_dm_connector_state before it is being null checked, this could
> > lead to a null pointer dereference.  Fix this by checking that
> > aconnector is null before dereferencing it.
> >
> > Addresses-Coverity: ("Dereference before null check")
> > Fixes: 5133c6241d9c ("drm/amd/display: Add MST atomic routines")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 5 ++---
> >   1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > index e3cda6984d28..72e677796a48 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> > @@ -193,12 +193,11 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
> >        * that blocks before commit guaranteeing that the state
> >        * is not gonna be swapped while still in use in commit tail */
> >
> > -     dm_conn_state = to_dm_connector_state(aconnector->base.state);
> > -
> > -
> >       if (!aconnector || !aconnector->mst_port)
> >               return false;
> >
> > +     dm_conn_state = to_dm_connector_state(aconnector->base.state);
> > +
> >       mst_mgr = &aconnector->mst_port->mst_mgr;
> >
> >       if (!mst_mgr->mst_state)
> >
>
> --
> Thanks,
> Mikita Lipski
> mikita.lipski@amd.com
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-08 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 14:38 [PATCH][next] drm/amd/display: fix dereference of pointer aconnector when it is null Colin King
2019-11-08 14:42 ` Mikita Lipski
2019-11-08 16:33   ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).