]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd/display: Check null pointers before using them
authorAlex Hung <alex.hung@amd.com>
Thu, 27 Jun 2024 23:38:16 +0000 (17:38 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 23 Jul 2024 21:07:11 +0000 (17:07 -0400)
[WHAT & HOW]
These pointers are null checked previously in the same function,
indicating they might be null as reported by Coverity. As a result,
they need to be checked when used again.

This fixes 3 FORWARD_NULL issue reported by Coverity.

Reviewed-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index ea1e2d8dcd8c35075422695be8c3a917b978d0b1..92774a871e982ea72a74e143fe315c57e8f6d04a 100644 (file)
@@ -7195,6 +7195,9 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
        int requested_bpc = drm_state ? drm_state->max_requested_bpc : 8;
        enum dc_status dc_result = DC_OK;
 
+       if (!dm_state)
+               return NULL;
+
        do {
                stream = create_stream_for_sink(connector, drm_mode,
                                                dm_state, old_stream,
@@ -9302,7 +9305,7 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
                if (acrtc)
                        old_crtc_state = drm_atomic_get_old_crtc_state(state, &acrtc->base);
 
-               if (!acrtc->wb_enabled)
+               if (!acrtc || !acrtc->wb_enabled)
                        continue;
 
                dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
@@ -9706,9 +9709,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 
                        DRM_INFO("[HDCP_DM] hdcp_update_display enable_encryption = %x\n", enable_encryption);
 
-                       hdcp_update_display(
-                               adev->dm.hdcp_workqueue, aconnector->dc_link->link_index, aconnector,
-                               new_con_state->hdcp_content_type, enable_encryption);
+                       if (aconnector->dc_link)
+                               hdcp_update_display(
+                                       adev->dm.hdcp_workqueue, aconnector->dc_link->link_index, aconnector,
+                                       new_con_state->hdcp_content_type, enable_encryption);
                }
        }