Commit f9277679 authored by Maxime Ripard's avatar Maxime Ripard

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: 9ec03d7f ("drm/vc4: kms: Wait on previous FIFO users before a commit")
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Reviewed-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.com>
Tested-by: default avatarJian-Hong Pan <jhp@endlessos.org>
Link: https://lore.kernel.org/r/20211117094527.146275-3-maxime@cerno.tech
parent 0c980a00
...@@ -354,7 +354,7 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state) ...@@ -354,7 +354,7 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state)
} }
old_hvs_state = vc4_hvs_get_old_global_state(state); old_hvs_state = vc4_hvs_get_old_global_state(state);
if (!old_hvs_state) if (IS_ERR(old_hvs_state))
return; return;
for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) { 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) ...@@ -410,8 +410,8 @@ static int vc4_atomic_commit_setup(struct drm_atomic_state *state)
unsigned int i; unsigned int i;
hvs_state = vc4_hvs_get_new_global_state(state); hvs_state = vc4_hvs_get_new_global_state(state);
if (!hvs_state) if (WARN_ON(IS_ERR(hvs_state)))
return -EINVAL; return PTR_ERR(hvs_state);
for_each_new_crtc_in_state(state, crtc, crtc_state, i) { for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
struct vc4_crtc_state *vc4_crtc_state = struct vc4_crtc_state *vc4_crtc_state =
...@@ -762,8 +762,8 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev, ...@@ -762,8 +762,8 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev,
unsigned int i; unsigned int i;
hvs_new_state = vc4_hvs_get_global_state(state); hvs_new_state = vc4_hvs_get_global_state(state);
if (!hvs_new_state) if (IS_ERR(hvs_new_state))
return -EINVAL; return PTR_ERR(hvs_new_state);
for (i = 0; i < ARRAY_SIZE(hvs_new_state->fifo_state); i++) for (i = 0; i < ARRAY_SIZE(hvs_new_state->fifo_state); i++)
if (!hvs_new_state->fifo_state[i].in_use) if (!hvs_new_state->fifo_state[i].in_use)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment