linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/amd/display: fix dereference before NULL check
@ 2021-12-26 11:16 José Expósito
  2021-12-27 17:57 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: José Expósito @ 2021-12-26 11:16 UTC (permalink / raw)
  To: harry.wentland
  Cc: sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, charlene.liu, amd-gfx,
	dri-devel, linux-kernel, José Expósito

The "plane_state" pointer was access before checking if it was NULL.

Avoid a possible NULL pointer dereference by accessing the plane
address after the check.

Addresses-Coverity-ID: 1493892 ("Dereference before null check")
Fixes: 3f68c01be9a22 ("drm/amd/display: add cyan_skillfish display support")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>

---

v2:

 - Fix coverity report ID

 - Add Reviewed-by tag (thanks to Harry Wentland)
---
 drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
index cfd09b3f705e..fe22530242d2 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
@@ -134,11 +134,12 @@ void dcn201_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)
 	PHYSICAL_ADDRESS_LOC addr;
 	struct dc_plane_state *plane_state = pipe_ctx->plane_state;
 	struct dce_hwseq *hws = dc->hwseq;
-	struct dc_plane_address uma = plane_state->address;
+	struct dc_plane_address uma;
 
 	if (plane_state == NULL)
 		return;
 
+	uma = plane_state->address;
 	addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, &addr);
 
 	plane_address_in_gpu_space_to_uma(hws, &uma);
-- 
2.25.1


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

* Re: [PATCH v2] drm/amd/display: fix dereference before NULL check
  2021-12-26 11:16 [PATCH v2] drm/amd/display: fix dereference before NULL check José Expósito
@ 2021-12-27 17:57 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2021-12-27 17:57 UTC (permalink / raw)
  To: José Expósito
  Cc: Wentland, Harry, Charlene Liu, Leo (Sunpeng) Li, xinhui pan,
	Siqueira, Rodrigo, LKML, amd-gfx list, Dave Airlie,
	Maling list - DRI developers, Deucher, Alexander,
	Christian Koenig

Applied.  Thanks!

Alex

On Sun, Dec 26, 2021 at 6:16 AM José Expósito <jose.exposito89@gmail.com> wrote:
>
> The "plane_state" pointer was access before checking if it was NULL.
>
> Avoid a possible NULL pointer dereference by accessing the plane
> address after the check.
>
> Addresses-Coverity-ID: 1493892 ("Dereference before null check")
> Fixes: 3f68c01be9a22 ("drm/amd/display: add cyan_skillfish display support")
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> ---
>
> v2:
>
>  - Fix coverity report ID
>
>  - Add Reviewed-by tag (thanks to Harry Wentland)
> ---
>  drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
> index cfd09b3f705e..fe22530242d2 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
> @@ -134,11 +134,12 @@ void dcn201_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)
>         PHYSICAL_ADDRESS_LOC addr;
>         struct dc_plane_state *plane_state = pipe_ctx->plane_state;
>         struct dce_hwseq *hws = dc->hwseq;
> -       struct dc_plane_address uma = plane_state->address;
> +       struct dc_plane_address uma;
>
>         if (plane_state == NULL)
>                 return;
>
> +       uma = plane_state->address;
>         addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, &addr);
>
>         plane_address_in_gpu_space_to_uma(hws, &uma);
> --
> 2.25.1
>

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

end of thread, other threads:[~2021-12-27 17:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-26 11:16 [PATCH v2] drm/amd/display: fix dereference before NULL check José Expósito
2021-12-27 17:57 ` 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).