Skip to content

Commit 4437c11

Browse files
Dan CarpenterRoland Scheidegger
authored andcommitted
drm/vmwgfx: Fix two list_for_each loop exit tests
These if statements are supposed to be true if we ended the list_for_each_entry() loops without hitting a break statement but they don't work. In the first loop, we increment "i" after the "if (i == unit)" condition so we don't necessarily know that "i" is not equal to unit at the end of the loop. In the second loop we exit when mode is not pointing to a valid drm_display_mode struct so it doesn't make sense to check "mode->type". Fixes: a278724 ("drm/vmwgfx: Implement fbdev on kms v2") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Signed-off-by: Roland Scheidegger <[email protected]>
1 parent 1d2c0c5 commit 4437c11

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,7 +2575,7 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
25752575
++i;
25762576
}
25772577

2578-
if (i != unit) {
2578+
if (&con->head == &dev_priv->dev->mode_config.connector_list) {
25792579
DRM_ERROR("Could not find initial display unit.\n");
25802580
ret = -EINVAL;
25812581
goto out_unlock;
@@ -2599,13 +2599,13 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
25992599
break;
26002600
}
26012601

2602-
if (mode->type & DRM_MODE_TYPE_PREFERRED)
2603-
*p_mode = mode;
2604-
else {
2602+
if (&mode->head == &con->modes) {
26052603
WARN_ONCE(true, "Could not find initial preferred mode.\n");
26062604
*p_mode = list_first_entry(&con->modes,
26072605
struct drm_display_mode,
26082606
head);
2607+
} else {
2608+
*p_mode = mode;
26092609
}
26102610

26112611
out_unlock:

0 commit comments

Comments
 (0)