Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp442560iog; Mon, 13 Jun 2022 06:06:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4EqxeJ8pVmzxI55q3Pym1NNEYxiP+RXrxBV41L+nMglCFLiuVNBq/o7i2NZnL2Plo84t8 X-Received: by 2002:a17:902:d54d:b0:165:13ac:7d60 with SMTP id z13-20020a170902d54d00b0016513ac7d60mr58572398plf.2.1655125560415; Mon, 13 Jun 2022 06:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125560; cv=none; d=google.com; s=arc-20160816; b=BhiTYDTtjPmIYEQSBK6FS7e/cYVx9b/P4y8wzswTYNoru3Tkg26zpyisu9MMFNgDaq sMH/pS/5dS0qpwxZ6mA9M5Aovyijofd8bYTOONfhvA8iAqBXVMZ666CTr4A6IjTxITy9 uBOFVhtZg3GTEdmGDj2fCYQrDjaVee91oqtuJ5oAWP6oayoGVFwx413F6ZJZMV3EqXmf W+W3Itn4EGvSqqIGUIlHIWnowKSdCjX5B4JvsZ2Ymp1ASBZJdzH/svUEBx+Bfl6n2XZZ fM0sQhoI1/WLUcloGxYq/zqK6ooTF+2YcGgvKly3FRuWblXddcORSmHDDlj+Rn39Bgm/ 8dKw== 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=EmM3Ie+bGd2l/iFpQQq6YghloUtSzGZF1CUaQqeuT0o=; b=y5vV0DRbS1N8aoGo+v0FDrBo7hc7m3R/kJTDmbhFmO/b2j+qqJKG89x0XWm9q8Pb5U yC0+OYUxoMdbqbQQZTahkSKjNYJSRLCiWEDF64c1YnReaKs2JmR6EGvfM14S1fubEiLM heneFJiUnrSGvUMad/1gxLDQm142oYm6SYrcmRESQtUCrtCjLqR5kmLjrn31/diLfice qdGioP2m0USjAku3Dme83XmJEfqLgy3Wzgqfgnq7ZBxbNhjD5Jwm8cvfd67Vbotub/w3 Ejkvh1a757Eo8eM5FLPRCsh9LxflXTXqSIFXRbluvI3Kd30+8KEEz3UY9K0o68arenbz +VoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=feE+B11h; 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 i7-20020a170902c94700b0016360b6cec1si10451090pla.230.2022.06.13.06.05.39; Mon, 13 Jun 2022 06:06:00 -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=feE+B11h; 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 S1349241AbiFMK5C (ORCPT + 99 others); Mon, 13 Jun 2022 06:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349565AbiFMKyY (ORCPT ); Mon, 13 Jun 2022 06:54:24 -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 158CD2F661; Mon, 13 Jun 2022 03:28:16 -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 35BFEB80EA7; Mon, 13 Jun 2022 10:28:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A52F0C34114; Mon, 13 Jun 2022 10:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116094; bh=XEYdQj+nG/p83wdweF1uBpntbavIDU+Y+1Fsi+0wt+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=feE+B11hLeynWEzvLHV5ROLvXO1s0y12Oh3ta6cwtLFJIIe84RMZqqOCjsY6RvVlf qIteigUGsFa5Sw0JDwXrj0SmmuIfIu+KzZCG83C1bwMKI9RmsvwzSpFRQaJzG8jV7/ U02aYgA0L7RiJCJ5PAgNJW3zPZ3dUWgOPBQPSHQw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Patrik Jakobsson Subject: [PATCH 4.14 131/218] gma500: fix an incorrect NULL check on list iterator Date: Mon, 13 Jun 2022 12:09:49 +0200 Message-Id: <20220613094924.553713522@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@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=-8.3 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,T_SCC_BODY_TEXT_LINE 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 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 @@ -543,14 +543,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)