Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2173461iof; Tue, 7 Jun 2022 22:09:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9cVAOeG1XvYclyqk5aXz42pV+sn48aymxJOGQSAM4pXwNhFlFDR/s9IYwQZ4XxRY7NaOh X-Received: by 2002:a17:902:d2c9:b0:163:bdee:b2df with SMTP id n9-20020a170902d2c900b00163bdeeb2dfmr32667596plc.98.1654664993750; Tue, 07 Jun 2022 22:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654664993; cv=none; d=google.com; s=arc-20160816; b=F62GpUibE5tMS3lV+tsBxyzP1J5Scd6XASfMWNhczV34BM+w3Ijwbu4vh7+yyDb6kQ SZxGCxAQhFGAAbjR55xnbXyt0xM/fB/z2Ed+g/VjR3tiYyJAmDFU1/Ab6/9qjmsYmztr knhYDjd+hH+tDFteo5/0P/jmaHypHsQouFbnd+c0W1A6n5Y2RRfYvLsV2+Ragyq9yBIF MxaSrEU3n1o/j354IN4aXlxUENyJhFThwCePTE+h/wTtmd5nF/3+jg6aTL/PaEYQt7wI C203jo2n35CRcUupocp7hZ74b96Gw94qOZKwMqNcEiSVCjApFRW7zrrhBkNQ/8OCnpAJ nrOg== 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=AL0kMNR2dgWF5qeGrWhgIhHjxKWK+N3N82z+opOapzk=; b=V3uvTL/fDph70pdnFqfzjxP3nVN5ngbPlOzH5P2D2gCId+EfFNZGMsvkuIB4UbLs5B MRB1vhsZ261q3EFLj0pny+IMu1wZ5WNljK5ykPKQzcNePKwQBSDh1DttTsyeTQ7yxu76 RVJQHDo9NTVYi5J+cSHt9G6E3VMobTxjT+Arc/SKTUuslnDkFRMtMLORPysIS2Y+yCyn lctr7ovcB4wxIRtF6LATRdyMBoH9J08pDsHAfN53pbUTgP1Y9fwLhtnY02T6n7xjF7L+ ZOV+b1aDzbYXSVUL8Rd2r9FRw+H0okexiAhBUMxGzmB38Ai/efOPs12DTEMWBYX2LXyL KWdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JWh2oqHH; 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 q68-20020a632a47000000b003fcda70f160si23157142pgq.784.2022.06.07.22.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:09:53 -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=JWh2oqHH; 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 12E082F0F40; Tue, 7 Jun 2022 21:40:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350734AbiFGSNr (ORCPT + 99 others); Tue, 7 Jun 2022 14:13:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348889AbiFGRuU (ORCPT ); Tue, 7 Jun 2022 13:50:20 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B6FB136437; Tue, 7 Jun 2022 10:37:25 -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 sin.source.kernel.org (Postfix) with ESMTPS id 96E13CE23E2; Tue, 7 Jun 2022 17:37:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90F9CC34115; Tue, 7 Jun 2022 17:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623439; bh=a9ZKlcBnYsnE8aDqjIFcOyx82PBbPcD5L2D+T4nFJj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWh2oqHHBUMN3+I4ggqnUAqGtxK4clCbUxyLOaefPwm5tPnjir1zb2SWIbO74bWMw Q9gbnXnU0iMiOOm+SJRRKl3YzVGuyRn5u5wxHhvV7N6O10yDxGgHm6wvU39sskJd9e Hpq3fvq8zaO5RJ88RiRXARXN5Tvx1CR0ZdmsBkc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Patrik Jakobsson Subject: [PATCH 5.10 416/452] gma500: fix an incorrect NULL check on list iterator Date: Tue, 7 Jun 2022 19:04:33 +0200 Message-Id: <20220607164920.952632644@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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 bdef417d84536715145f6dc9cc3275c46f26295a upstream. The bug is here: return crtc; The list iterator value 'crtc' 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, return 'crtc' when found, otherwise return NULL. Cc: stable@vger.kernel.org fixes: 89c78134cc54d ("gma500: Add Poulsbo support") Signed-off-by: Xiaomeng Tong Signed-off-by: Patrik Jakobsson Link: https://patchwork.freedesktop.org/patch/msgid/20220327052028.2013-1-xiam0nd.tong@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/gma500/psb_intel_display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/gma500/psb_intel_display.c +++ b/drivers/gpu/drm/gma500/psb_intel_display.c @@ -536,14 +536,15 @@ void psb_intel_crtc_init(struct drm_devi struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev, int pipe) { - struct drm_crtc *crtc = NULL; + struct drm_crtc *crtc; list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { struct gma_crtc *gma_crtc = to_gma_crtc(crtc); + if (gma_crtc->pipe == pipe) - break; + return crtc; } - return crtc; + return NULL; } int gma_connector_clones(struct drm_device *dev, int type_mask)