Skip to contentSkip to conversation

drm/amd/display: fix dereference before NULL check

PATCH Applied José Expósito 2 participants 2 messages Dec 26, 2021 – Dec 27, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd/display: fix dereference before NULL check

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")

---

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(-)
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c +2 -1
index cfd09b3f705e..fe22530242d2 100644
@@ -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);
Signature · 1 line
2.25.1
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 43 lines · 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")

---

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(-)
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c +2 -2
index cfd09b3f705e..fe22530242d2 100644
@@ -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