Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1240649pxa; Thu, 20 Aug 2020 06:31:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4OgDRg07rw3BqVxT/NqMTAkwaKMaEEBJjUYvvTqNFvAYQ++7Hh7D3Fx3Tl11tqRhessuu X-Received: by 2002:a50:c3c4:: with SMTP id i4mr2905042edf.244.1597930293278; Thu, 20 Aug 2020 06:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597930293; cv=none; d=google.com; s=arc-20160816; b=byK9Kz/EvTuJ/slYG8DU6o5iZpmIP1BzUwrGdwWnDv+0Rg8QczUhtb4hcbCe570glc 7+IEX65GXMA86yh2kBrWd2fy4mIMTYttdcOQ1bnq0w5PPToVE25gkSykWZWbOuR57npY DL2YHotNHyUiW2YZy1xqKlyMmN03+1LtjXdL3DN5pXLcxCBOOp83bTT8UVolJQz1/zRg sKO/7/QYOvb6N+0SECz0PaE+Phh6VwaACow3I17xM32hlXlTRyG554uWSpEw4EQt8jjV O8vdqjcEfArzFAWGkIbdv903D9hJFV8cUrlq1x+P3TakenrO8QWLoGbPNkGGzotoJkwy nIpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AtXFExkLxR1tpT1nqpeFl8EgJfLHPwgfgamMkTzS1Y4=; b=gVRKhCW7I7ihiKUdtXNsJzSYz5L2nNFVGbiLbYoe44jgdWe7Cnikv1ae6Rg+CvUPKn 5SEXwsmoMY26vJgZXjnVeCD1qGwqgjhtQLAw/RRAY/30+qEteWIuOYozHyD4gTgXtMyE RKYAMB7ahJfzJQBoga+MkHgjkaqFCYwLD/1xePaZZCxftYwF0wNfuRlEKXjKkJ5avKAa XIhByan+K+9H6rn2Gz3jL//mVbIyIJ+39EveU7B/CUU9Ers/wIW60+sLyn7K1SjZBg/L C8kpTznRnOwXcjr5k1C2Pe6qHPTsfptYlF/Vuq/R/BcoJQzoXkt3soGfn61SgxRu7JK8 q7UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PASYbDjI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l21si1309329edw.181.2020.08.20.06.31.08; Thu, 20 Aug 2020 06:31:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PASYbDjI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728788AbgHTNa3 (ORCPT + 99 others); Thu, 20 Aug 2020 09:30:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:45376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728380AbgHTJcu (ORCPT ); Thu, 20 Aug 2020 05:32:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DAEAF22B4B; Thu, 20 Aug 2020 09:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915970; bh=BvelV7rj7pX8LClD7CfT1GkoCmXsCtbsF1V8T+D2ddY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PASYbDjI65LDqwfZhMeO43BKFxg1GlLUdbg+jlX/0x8PJkqc2zg4/XWfWmhb5KebD iJgXboeCNIQIx97cJc5NksClGec952s8y1XVxwZqZE6GQ+sSfRyK2VeJDGVtSKisMQ WRWTcdZ5bOc4ESTAaO8BWjDp/JcjugtqBtQhn8nY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Roland Scheidegger , Sasha Levin Subject: [PATCH 5.8 199/232] drm/vmwgfx: Fix two list_for_each loop exit tests Date: Thu, 20 Aug 2020 11:20:50 +0200 Message-Id: <20200820091622.446084378@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 4437c1152ce0e57ab8f401aa696ea6291cc07ab1 ] 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: a278724aa23c ("drm/vmwgfx: Implement fbdev on kms v2") Signed-off-by: Dan Carpenter Reviewed-by: Roland Scheidegger Signed-off-by: Roland Scheidegger Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 04d66592f6050..b7a9cee69ea72 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2578,7 +2578,7 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv, ++i; } - if (i != unit) { + if (&con->head == &dev_priv->dev->mode_config.connector_list) { DRM_ERROR("Could not find initial display unit.\n"); ret = -EINVAL; goto out_unlock; @@ -2602,13 +2602,13 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv, break; } - if (mode->type & DRM_MODE_TYPE_PREFERRED) - *p_mode = mode; - else { + if (&mode->head == &con->modes) { WARN_ONCE(true, "Could not find initial preferred mode.\n"); *p_mode = list_first_entry(&con->modes, struct drm_display_mode, head); + } else { + *p_mode = mode; } out_unlock: -- 2.25.1