drm/msm/snapshot: Do not keep an error pointer as the atomic state
PATCH 1/1 drm/msm/snapshot: Do not keep an error pointer as the atomic state
The drm_atomic_helper_duplicate_state() function returns ERR_PTR(-ENOMEM) when it fails to allocate. msm_disp_capture_atomic_state() stores the result in the disp_state->atomic_state variable without a check. Later msm_disp_state_print() passes it to drm_atomic_print_new_state() and msm_disp_state_free() to drm_atomic_commit_put(). Both dereference the error pointer.
Store the state only if the call succeeds. The snapshot then has no atomic state, which both users already handle.
Fixes 98659487b845 ("drm/msm: add support to take dpu snapshot")
Signed-off-by Anton Protopopov <[email protected]>
---
(Just accidentally bumped into this, while working on BPF stuff...)
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +4 -2
@@ -111,6 +111,7 @@ static void msm_disp_capture_atomic_state(struct msm_disp_state *disp_state) {struct drm_device *ddev;struct drm_modeset_acquire_ctx ctx; +struct drm_atomic_commit *state;ktime_get_real_ts64 (&disp_state->time);
@@ -121,8 +122,9 @@ static void msm_disp_capture_atomic_state(struct msm_disp_state *disp_state)while (drm_modeset_lock_all_ctx (ddev, &ctx) !=0 )drm_modeset_backoff (&ctx); - disp_state->atomic_state =drm_atomic_helper_duplicate_state (ddev, - &ctx); + state =drm_atomic_helper_duplicate_state (ddev, &ctx); +if (!IS_ERR (state)) + disp_state->atomic_state = state;drm_modeset_drop_locks (&ctx);drm_modeset_acquire_fini (&ctx); }
Signature · 1 line
2.54.0 (Apple Git-157)