Skip to content

Commit 46cc2d7

Browse files
committed
drm/client: Restrict the plane_state scope
The drm_client_modeset_commit_atomic function uses two times the plane_state variable in inner blocks of code, but the variable has a scope global to this function. This will lead to inadvertent devs to reuse the variable in the second block with the value left by the first, without any warning from the compiler since value would have been initialized. Fix this by moving the variable declaration to the proper scope. Reviewed-by: Noralf Trønnes <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/8bd9696ea915a4ad08be6d93a4d9565e8d6aa2f3.1560783090.git-series.maxime.ripard@bootlin.com
1 parent 772cd52 commit 46cc2d7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/gpu/drm/drm_client_modeset.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ EXPORT_SYMBOL(drm_client_panel_rotation);
861861
static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool active)
862862
{
863863
struct drm_device *dev = client->dev;
864-
struct drm_plane_state *plane_state;
865864
struct drm_plane *plane;
866865
struct drm_atomic_state *state;
867866
struct drm_modeset_acquire_ctx ctx;
@@ -879,6 +878,8 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool
879878
state->acquire_ctx = &ctx;
880879
retry:
881880
drm_for_each_plane(plane, dev) {
881+
struct drm_plane_state *plane_state;
882+
882883
plane_state = drm_atomic_get_plane_state(state, plane);
883884
if (IS_ERR(plane_state)) {
884885
ret = PTR_ERR(plane_state);
@@ -901,6 +902,8 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool
901902
unsigned int rotation;
902903

903904
if (drm_client_panel_rotation(mode_set, &rotation)) {
905+
struct drm_plane_state *plane_state;
906+
904907
/* Cannot fail as we've already gotten the plane state above */
905908
plane_state = drm_atomic_get_new_plane_state(state, primary);
906909
plane_state->rotation = rotation;

0 commit comments

Comments
 (0)