Skip to content

Commit dba9e34

Browse files
gscuimripard
authored andcommitted
drm/vc4: kms: Fix IS_ERR() vs NULL check for vc4_kms
The drm_atomic_get_new_private_obj_state() function returns NULL on error path, drm_atomic_get_old_private_obj_state() function returns NULL on error path, too, they does not return error pointers. By the way, vc4_hvs_get_new/old_global_state() should return ERR_PTR(-EINVAL), otherwise there will be null-ptr-defer issue, such as follows: In function vc4_atomic_commit_tail(): |-- old_hvs_state = vc4_hvs_get_old_global_state(state); <-- return NULL |-- if (WARN_ON(IS_ERR(old_hvs_state))) <-- no return |-- unsigned long state_rate = max(old_hvs_state->core_clock_rate, new_hvs_state->core_clock_rate); <-- null-ptr-defer Fixes: 9ec03d7 ("drm/vc4: kms: Wait on previous FIFO users before a commit") Signed-off-by: Gaosheng Cui <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f352262 commit dba9e34

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpu/drm/vc4/vc4_kms.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ vc4_hvs_get_new_global_state(struct drm_atomic_state *state)
197197
struct drm_private_state *priv_state;
198198

199199
priv_state = drm_atomic_get_new_private_obj_state(state, &vc4->hvs_channels);
200-
if (IS_ERR(priv_state))
201-
return ERR_CAST(priv_state);
200+
if (!priv_state)
201+
return ERR_PTR(-EINVAL);
202202

203203
return to_vc4_hvs_state(priv_state);
204204
}
@@ -210,8 +210,8 @@ vc4_hvs_get_old_global_state(struct drm_atomic_state *state)
210210
struct drm_private_state *priv_state;
211211

212212
priv_state = drm_atomic_get_old_private_obj_state(state, &vc4->hvs_channels);
213-
if (IS_ERR(priv_state))
214-
return ERR_CAST(priv_state);
213+
if (!priv_state)
214+
return ERR_PTR(-EINVAL);
215215

216216
return to_vc4_hvs_state(priv_state);
217217
}

0 commit comments

Comments
 (0)