Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5158776pxb; Mon, 28 Mar 2022 08:45:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygRx83d4OYm4I24ZSIXRISg+qmMjQAV5CSqUASbR084boTwiAeI4c6XA2lUDmQcbZ7MO92 X-Received: by 2002:a17:906:5641:b0:6da:8691:3fcc with SMTP id v1-20020a170906564100b006da86913fccmr27753523ejr.50.1648482313079; Mon, 28 Mar 2022 08:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648482313; cv=none; d=google.com; s=arc-20160816; b=R6XRGMhj1EwYCtYWIOk9udtpj5sl0/hRyoNE/0lqir7O4oIZo+CBxc5RAWMpQp4Goc zWm39cthqca0BmL8ProJJQ8cMGAHG6bQhgKuHuzKXFHboWS3h+8IzA69X7UGtOzkpWj4 j3wLLgUmaWQcd2FftrJ+LwM5r3QFTqAdMDSl5OwjhNeJHvTePxiGvSbNEaz6iSHqyQAN JEMfMmuGwpjWHdnCRGsNB2eE0VTuhlFS0RiBR+RLF8dh36011qJoKhJcStciLRlu9TzY 9ErAoqV1jV1uvTeg02Rpv9bNazRahyvAPNURSsPs6Ghrlbs6q7fTEsZOWnJfj+6OSNLD Kgyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:mime-version:dkim-signature; bh=pV29UjFYmfGiilWwyQNlVjFasUPj3jYxTXkmhIEc+XM=; b=ML+buaT5hcQO9xZWpFXt4JQeYuxWjmIhw5bL72PtAaoa2US1WzcA/GjMdorgZ3HyaM NeHqk5vrglERND5VSyhUgFHmhNmHqjehYHFgLTvnJ05Xw4SHGBkHjeoBvQ+I7HD1lQAS jzIVFj6raVVslFpAlkvA9SLHtpS7qY7InL+XTeuMhoIT7j6Cqn62AHXKm8ETRgvWpIGa j1YGzgofLqxxu7XGVMbZqDeEUAES9jyNZ/0X4pYn8Gcn7Hfk7nvgrUNpKjdDHKdAN7A5 EKRrH1VVk3NW/JUCGfmrJRla3CqupxrbEPFMDb2ltZ1VFptYLtL/KdhKS/XB8SKujmzS liEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=BHU0kAa6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z21-20020aa7cf95000000b00418c2b5bf27si14461299edx.521.2022.03.28.08.44.47; Mon, 28 Mar 2022 08:45:13 -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=fail header.i=@kapsi.fi header.s=20161220 header.b=BHU0kAa6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236867AbiC0WPR (ORCPT + 99 others); Sun, 27 Mar 2022 18:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236863AbiC0WPQ (ORCPT ); Sun, 27 Mar 2022 18:15:16 -0400 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 737CF49F8A; Sun, 27 Mar 2022 15:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:Content-Type:Message-ID:References: In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pV29UjFYmfGiilWwyQNlVjFasUPj3jYxTXkmhIEc+XM=; b=BHU0kAa6aPENeSDuCOZPHe56vV qpF2gdxkZMMrvTtlKbEeVlVbwiTgG6JyTb8gftMEhKrtLpNWaa+2q0BPH+65voWXa1q7NN74q6Xdk th1/kUkA2/12kAlPqkbJPBL3Si86W2SSXNOyEEuh7Fp3oFnLn4XHtogu9xe0fsk6lC6HHPI+/SoWe /NHJMOZOmG8fXRXW03DiEq5WOfqfZ0XQGrYz4QtaSqmmpE711w5bK9DZIDbCGu/oQ2Sk/YnoRC/E/ XNqvj0NZF2EzGzZSoW1oBeq1O9wY8LiKpiKXFVd2l2KSn+jaQ13cZcuNRw8ppEu2TFNTZf8SvCShR WPYY8utA==; Received: from webng-gw.kapsi.fi ([91.232.154.200] helo=roundcube.kapsi.fi) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nYb8V-00024d-Uh; Mon, 28 Mar 2022 01:13:23 +0300 MIME-Version: 1.0 Date: Mon, 28 Mar 2022 01:13:21 +0300 From: Jyri Sarha To: Xiaomeng Tong Cc: tomba@kernel.org, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator In-Reply-To: <20220327061516.5076-1-xiam0nd.tong@gmail.com> References: <20220327061516.5076-1-xiam0nd.tong@gmail.com> Message-ID: X-Sender: jyri.sarha@iki.fi Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 91.232.154.200 X-SA-Exim-Mail-From: jyri.sarha@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 2022-03-27 9:15, Xiaomeng Tong wrote: > 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 Thanks for the patch. Good catch. Reviewed-by: Jyri Sarha Tested-by: Jyri Sarha I'll apply this to drm-misc-next in couple of days. Best regards, Jyri > --- > 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 7594cf6e186e..3b86d002ef62 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__);