Skip to content

Commit f927767

Browse files
committed
drm/vc4: kms: Fix return code check
The HVS global state functions return an error pointer, but in most cases we check if it's NULL, possibly resulting in an invalid pointer dereference. Fixes: 9ec03d7 ("drm/vc4: kms: Wait on previous FIFO users before a commit") Signed-off-by: Maxime Ripard <[email protected]> Reviewed-by: Dave Stevenson <[email protected]> Tested-by: Jian-Hong Pan <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0c980a0 commit f927767

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/gpu/drm/vc4/vc4_kms.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state)
354354
}
355355

356356
old_hvs_state = vc4_hvs_get_old_global_state(state);
357-
if (!old_hvs_state)
357+
if (IS_ERR(old_hvs_state))
358358
return;
359359

360360
for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
@@ -410,8 +410,8 @@ static int vc4_atomic_commit_setup(struct drm_atomic_state *state)
410410
unsigned int i;
411411

412412
hvs_state = vc4_hvs_get_new_global_state(state);
413-
if (!hvs_state)
414-
return -EINVAL;
413+
if (WARN_ON(IS_ERR(hvs_state)))
414+
return PTR_ERR(hvs_state);
415415

416416
for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
417417
struct vc4_crtc_state *vc4_crtc_state =
@@ -762,8 +762,8 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev,
762762
unsigned int i;
763763

764764
hvs_new_state = vc4_hvs_get_global_state(state);
765-
if (!hvs_new_state)
766-
return -EINVAL;
765+
if (IS_ERR(hvs_new_state))
766+
return PTR_ERR(hvs_new_state);
767767

768768
for (i = 0; i < ARRAY_SIZE(hvs_new_state->fifo_state); i++)
769769
if (!hvs_new_state->fifo_state[i].in_use)

0 commit comments

Comments
 (0)