From patchwork Thu Aug 20 09:22:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E719C433E3 for ; Thu, 20 Aug 2020 11:27:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51F2B2173E for ; Thu, 20 Aug 2020 11:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597922852; bh=IgSK+OEM7nPONRaTMfkYnENa9K14IChnzu45ltbM65E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=y7fe3gC8VQNOIxVbwJ5UqvbLSkJEUeeIjYw/QP8NSTubEF6PTWiXG4/1Vn7hAxem/ HuHAuRk2YEOcxxqBbXrjugDvvX2go6+nTinXlJ2YAqauZdwui1kirx0uD9aroVFPyk D3guva37e1LtJIt9dmn2OVFoM/gn0kBevQgVD1Hk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730560AbgHTL1b (ORCPT ); Thu, 20 Aug 2020 07:27:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:34558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730652AbgHTKGC (ORCPT ); Thu, 20 Aug 2020 06:06:02 -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 439C32067C; Thu, 20 Aug 2020 10:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597917961; bh=IgSK+OEM7nPONRaTMfkYnENa9K14IChnzu45ltbM65E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MprWmzhnx4FCpYSQVSU8CrOFJMAI+kk8k3QWhp6L3JwLFgzxqGfBxmG4BlkpiGKVG /u+KhjNfFKGhwueRy+7Vb+Y1eN410jWb9kw4tQlL1szzx2tcAMuJtHRVRllosO5sK9 MgoilMd8IcOTQjnvadgG5EkYmEC2E1kN9KQyPknA= 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 4.9 203/212] drm/vmwgfx: Fix two list_for_each loop exit tests Date: Thu, 20 Aug 2020 11:22:56 +0200 Message-Id: <20200820091612.600613190@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091602.251285210@linuxfoundation.org> References: <20200820091602.251285210@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 33ca24ab983e1..39ac7566b705b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2109,7 +2109,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"); return -EINVAL; } @@ -2131,13 +2131,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; } return 0;