Skip to content

Commit 3f397cd

Browse files
srishanmalexdeucher
authored andcommitted
drm/amd/display: Add NULL pointer checks in dm_force_atomic_commit()
This commit updates the dm_force_atomic_commit function to replace the usage of PTR_ERR_OR_ZERO with IS_ERR for checking error states after retrieving the Connector (drm_atomic_get_connector_state), CRTC (drm_atomic_get_crtc_state), and Plane (drm_atomic_get_plane_state) states. The function utilized PTR_ERR_OR_ZERO for error checking. However, this approach is inappropriate in this context because the respective functions do not return NULL; they return pointers that encode errors. This change ensures that error pointers are properly checked using IS_ERR before attempting to dereference. Cc: Harry Wentland <harry.wentland@amd.com> Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> Cc: Tom Chung <chiahsuan.chung@amd.com> Cc: Roman Li <roman.li@amd.com> Cc: Alex Hung <alex.hung@amd.com> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 42a6667 commit 3f397cd

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10602,26 +10602,32 @@ static int dm_force_atomic_commit(struct drm_connector *connector)
1060210602
*/
1060310603
conn_state = drm_atomic_get_connector_state(state, connector);
1060410604

10605-
ret = PTR_ERR_OR_ZERO(conn_state);
10606-
if (ret)
10605+
/* Check for error in getting connector state */
10606+
if (IS_ERR(conn_state)) {
10607+
ret = PTR_ERR(conn_state);
1060710608
goto out;
10609+
}
1060810610

1060910611
/* Attach crtc to drm_atomic_state*/
1061010612
crtc_state = drm_atomic_get_crtc_state(state, &disconnected_acrtc->base);
1061110613

10612-
ret = PTR_ERR_OR_ZERO(crtc_state);
10613-
if (ret)
10614+
/* Check for error in getting crtc state */
10615+
if (IS_ERR(crtc_state)) {
10616+
ret = PTR_ERR(crtc_state);
1061410617
goto out;
10618+
}
1061510619

1061610620
/* force a restore */
1061710621
crtc_state->mode_changed = true;
1061810622

1061910623
/* Attach plane to drm_atomic_state */
1062010624
plane_state = drm_atomic_get_plane_state(state, plane);
1062110625

10622-
ret = PTR_ERR_OR_ZERO(plane_state);
10623-
if (ret)
10626+
/* Check for error in getting plane state */
10627+
if (IS_ERR(plane_state)) {
10628+
ret = PTR_ERR(plane_state);
1062410629
goto out;
10630+
}
1062510631

1062610632
/* Call commit internally with the state we just constructed */
1062710633
ret = drm_atomic_commit(state);

0 commit comments

Comments
 (0)