Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp482544imn; Wed, 27 Jul 2022 11:26:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vnjtkcwKzNbGDvX4IgwPK9tMrbKFvw+eDFGH/idbrAQOkLuMUG3k8bOCPOrS9hpMNBaT9P X-Received: by 2002:a63:cf06:0:b0:41a:dbc4:1fce with SMTP id j6-20020a63cf06000000b0041adbc41fcemr16394946pgg.283.1658946396694; Wed, 27 Jul 2022 11:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946396; cv=none; d=google.com; s=arc-20160816; b=OpZ/zEEXhoJpV9JjCRlU2v7FdnbzjCUebGNU24nl8Owh/VBgxFEUtteZfabZm+oicr xnGUuNKizF9mU6k+IaVI1l+/Z8qE63YqO5QBeTAgBYEguCganLf9nWIvsy/oJoJjzUwJ WdqHOR/0Nle7CK2cGU/U+Coz12Dy4H8Gp9rEkxEHyDiTQ3gCOE1L1pwWLB1/gGl6BHAj 1wSR0siozjX6s4qxs80jMoK9bpLSSkF/AKuT0IwjFRG7hDKMwk4wV5a4W6I/tMG9OL/J Rb/fOcRAzoQna3Mj43QxIt54YDC6oZ76EUBr2ZITIC1N+H9y+RE++brkL1N5LuPEAxSE x7Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K1zq5LPNko/Y3at1K0VHtTRSpbVQVYcJWMiFeo84P8k=; b=MAUDD6rO4q97He9Vw0tV4zPqL/UE6GjOC13CUMz7z20pT6qwzPsl5rQ0GKbq5P4sh7 s7Vfukks2uNf/Jq8FraYzJjnaBigNcKo5MwB9GMPQt5ODTXzQphp/rxXaztZaHz8UxEC wFB6sECeYpMq/5q7i/Vgt1dvSl424SNdeUL2Zq/nFGGVupK9SJe9iRvjzY9TSt/qOgcC 3ALDaVs0HT5lJkHz0BJVCGTf9tQ3jyW3E/5UxOGLBHXJlSi2+eVeypvnIGWBTdGazjcT c8vWRR1ZqDtwflHeFcu6PFrFZP38bnRRb4N7TcFb92qFSW/AFNByub8+ChfD6dyD/gzg tF6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="T/k9Zl93"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a170902c94100b00168e8b8c884si8231362pla.56.2022.07.27.11.26.21; Wed, 27 Jul 2022 11:26:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="T/k9Zl93"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238110AbiG0Qdp (ORCPT + 99 others); Wed, 27 Jul 2022 12:33:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237497AbiG0QdI (ORCPT ); Wed, 27 Jul 2022 12:33:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AE7C54AC4; Wed, 27 Jul 2022 09:26:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF36761A15; Wed, 27 Jul 2022 16:26:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 057F1C433C1; Wed, 27 Jul 2022 16:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939170; bh=SreVxgwI6lBZVdb5SSYKJ3fcMWrE/33Vzt8CofhLAp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T/k9Zl93fb6IPvyHCi4hwX26/dxdbTysxky/Ikq0L+NKRNvAm34g92nUkPqhUjFyn EoSh4okYXgvlNStdtIcyPwQ/hjYG78cY8lJ7xKicb0FEFL8JzMggpEhFe12kypo8q5 78YMxAmAr5djyEWH3JuXovNbJZbexIn5n4be2LNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Jyri Sarha , Sasha Levin Subject: [PATCH 4.19 37/62] tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator Date: Wed, 27 Jul 2022 18:10:46 +0200 Message-Id: <20220727161005.641385999@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaomeng Tong [ Upstream commit 8b917cbe38e9b0d002492477a9fc2bfee2412ce4 ] The bug is here: if (!encoder) { The list iterator value 'encoder' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found. To fix the bug, use a new variable 'iter' as the list iterator, while use the original variable 'encoder' as a dedicated pointer to point to the found element. Cc: stable@vger.kernel.org Fixes: ec9eab097a500 ("drm/tilcdc: Add drm bridge support for attaching drm bridge drivers") Signed-off-by: Xiaomeng Tong Reviewed-by: Jyri Sarha Tested-by: Jyri Sarha Signed-off-by: Jyri Sarha Link: https://patchwork.freedesktop.org/patch/msgid/20220327061516.5076-1-xiam0nd.tong@gmail.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c index a2f623550ce3..9c1be0635b53 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c @@ -60,11 +60,13 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev, int tilcdc_add_component_encoder(struct drm_device *ddev) { struct tilcdc_drm_private *priv = ddev->dev_private; - struct drm_encoder *encoder; + struct drm_encoder *encoder = NULL, *iter; - list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head) - if (encoder->possible_crtcs & (1 << priv->crtc->index)) + list_for_each_entry(iter, &ddev->mode_config.encoder_list, head) + if (iter->possible_crtcs & (1 << priv->crtc->index)) { + encoder = iter; break; + } if (!encoder) { dev_err(ddev->dev, "%s: No suitable encoder found\n", __func__); -- 2.35.1