Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2196996iof; Tue, 7 Jun 2022 22:55:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS+RF0JB7uhr/Fr5owxTYLhHElrGe9louln1RJ4YC7IVZyXxInu63DVZJ7z3FjKQFFtkg+ X-Received: by 2002:a17:902:ee8d:b0:164:7dd:6cc6 with SMTP id a13-20020a170902ee8d00b0016407dd6cc6mr34184249pld.84.1654667734017; Tue, 07 Jun 2022 22:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667734; cv=none; d=google.com; s=arc-20160816; b=iDgTtSR/GpNEHtSnYjZhyxvf7UyK/OL99wdskMqe1kJzUlGxb7Gv3/i4lpiEO4+KY+ Ob4WnCOAhF1RTJd9ZJqxy8/bMGleFPniLiBhlYvVzqm0iw+/y34ni4wWO61TLD1pYiBo 5SRjXPtWlFpCZLylEOQDse3lS1eIAwHtN+WDjbgULd7mDL2dMWeIneCdZMPcmhDdya1b +vg7BxmhVjB3lisVfnYfajbnhFvOL2/Ug1zkReEvCQw+Y2qeYHwLE4ujkQfJV+W32d7N xIaZVotijpGqHk+9WdTAngZfJB7xEurbQIDEZD7VoCHxIICrhNWGdDVv/ePYvygfeZQz dTWg== 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=C1cWBZ1/dwmHM4yTQWHssNiDkPnihBX5AQOhRLlx/Rg=; b=CxbtYtV93SDo/hm+8qmtHq2QreQjNieQlDcVSTWehDvc/oXN7eJ5rVyFvRm16mhdxq 4nUB0SIbBsdi4EZBeqfUrwxQoYwQlb9iGiTL1sV9MlllYrqLvnsuIb2DaYNwf/FJ/gk/ nA1UZ0HI01kndNN1QJ9Ufp03Q326evXas+ZHlE41HWNs3abdfwTfPMvktN9bYXC926tF uBlFcra1NbqykoKAWD8k2rqt2LUo2k/2B7/UmuL0OCAFLChjKcFuZPYyHqnokEHqDANQ bY2Q8T8s2FGQAQvxOrVtKUZD62+NKgj3Vp3vOrsfTAuzSH0X+UEH+F4zhc+9IOj5gdEq fV8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oQVJsh39; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f23-20020a170902ab9700b00153b2d165f6si24923230plr.510.2022.06.07.22.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oQVJsh39; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 59E4626E92C; Tue, 7 Jun 2022 22:21:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236589AbiFHA6e (ORCPT + 99 others); Tue, 7 Jun 2022 20:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385270AbiFGWbU (ORCPT ); Tue, 7 Jun 2022 18:31:20 -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 88A79278528; Tue, 7 Jun 2022 12:24:29 -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 4B1F460B09; Tue, 7 Jun 2022 19:24:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57169C385A5; Tue, 7 Jun 2022 19:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629868; bh=u3BGt4PKsLXxAzxsq/aZZArjOH52aSbr80e3Qobz3pY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQVJsh39jYz0Bk/KBaUS4nUsSTMi9R9+WCugDWnUCX4I3JL3tkb0Fc9ZSLYuzKZwE 5QcPYSnWojBlaUsRTwYMRYCyFGkQh+iqAp0ourLiaQ5YYNq/m3TRRDYHKCfaIlAeTy jNqFUGWoMbKhMJxx2F2FDhwtU5ItsElx87QmBr90= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Jyri Sarha Subject: [PATCH 5.18 844/879] tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator Date: Tue, 7 Jun 2022 19:06:02 +0200 Message-Id: <20220607165027.350252782@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 commit 8b917cbe38e9b0d002492477a9fc2bfee2412ce4 upstream. 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: Greg Kroah-Hartman --- drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- 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_fin 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__);