Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2187889iof; Tue, 7 Jun 2022 22:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsHaHtBhr6TPGS39YqR2A/xgZS7sl4E1nFRvP+hcbWuiCRhQe6iCCJsNe53IKOKUPrWlzc X-Received: by 2002:a17:90b:2c0b:b0:1e3:25d3:e76f with SMTP id rv11-20020a17090b2c0b00b001e325d3e76fmr35335757pjb.150.1654666545355; Tue, 07 Jun 2022 22:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666545; cv=none; d=google.com; s=arc-20160816; b=Zm+3gDtX7nTkm6kYG+G1O2i/n1nPrZXvnrPthbrisn3kZJG8r0cCyB7lei8R9mAa8H KzQwaProbLq/xFw9HC6sE1knXk15knxxbQhwzrWaP7shcU0z/rGpjux562miTWN2WNJ5 v1LHk1pz5fQ3GlRuNqOHrVStY4prds2nswYj4+l/+USVApi3s0yPyB1rd1qSTwUDldwB urKHPMUYuR9Q+RtuGOdpxyct8juDqFfxBQXj2IMgeNvZ4gsmmIGDPx4HvGfyYDoqBRRB Nk+XTq+E0oxAS/USbjLcRiBE7ovOIpSADc6sFgWMYjsskEQ9Bv2TNJQPhcgLgm8H28lv x+PQ== 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=f3GaEd8x9gq8mMlHbUqU6TXF23tbAcTDVXQwr5K7coA=; b=wcDqPaIan9URz/CuFWm/Q77lb0U7h/tME9EZQwPPOnAyf5W9oIKshNKiXy/936w3jX wbQfJjTcxfvdYmVYwb3mznXf4b3hJ1jKzFlRa8Uaq88yyE2EI4Sh67K03yHaqP4+dvff 3Po8JJIUp0kVexgImKGksHOJEVo9sZR24ycDpnWH+P37IAR7Pmz7TefIZ9DLpn4vOeNM PkncsPp9YFfFlpvj4PAczg317zqQ41YtH4Pdd9PpZ0cp8z0xfYDNdhS+ArWX7kr//DsA tTu8atojTf6qU9719SCEV0gJBjS/9fbsVjPZYsPvwDBVg1swSSjGsD+6vlJinZWU0E/g k8JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0IOcc3Cc; 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 10-20020a630f4a000000b003fdd5d8af90si9052483pgp.129.2022.06.07.22.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:35:45 -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=0IOcc3Cc; 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A5CE310171D; Tue, 7 Jun 2022 22:13:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387875AbiFHAbG (ORCPT + 99 others); Tue, 7 Jun 2022 20:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384879AbiFGWbN (ORCPT ); Tue, 7 Jun 2022 18:31:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070D1278982; Tue, 7 Jun 2022 12:24:34 -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 ams.source.kernel.org (Postfix) with ESMTPS id 89CE1B8220B; Tue, 7 Jun 2022 19:24:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0528AC385A5; Tue, 7 Jun 2022 19:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629871; bh=ScxqRn4CyVuet+Fn9+6gsApj3gvQxxDLbl/1mrX6GRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0IOcc3CcBFLxdJ25B0FbLNYixQTJvMEoLPoBnZ0isdGued+cbcvhzgcEcHS1JFyNW Nu4C2seuRRS54m1u/1B76HlHdK85zfji4TTyT8Dy+8A1qBhnXIJ/dzbr2GHD1WK/Pd RfW2obO7oMHTXs3pmpeJZMXd2ft6kFSMijCACCNE= 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.18 845/879] gma500: fix an incorrect NULL check on list iterator Date: Tue, 7 Jun 2022 19:06:03 +0200 Message-Id: <20220607165027.378736782@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 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 @@ -535,14 +535,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)