Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp447864iog; Mon, 13 Jun 2022 06:10:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNiLPXOmviaSQRwgicRZPNmoSdCV+Lil/RlT+NrJjaOnLsU1jKpQ7hGhRvgCuk9tTblYuR X-Received: by 2002:a05:6402:459:b0:431:665f:11ce with SMTP id p25-20020a056402045900b00431665f11cemr42800048edw.35.1655125734316; Mon, 13 Jun 2022 06:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125734; cv=none; d=google.com; s=arc-20160816; b=aALwTIv+X/BQ6G1VMyuIe6iZRWxJXkfdTCAtg7LHLXd+ZwfS0WOiqHJLedeH1SMe+x Xl4OVEYpEoS6giK5LkkjrgxD49KmqC68UI4VSoQamcNEMaMpJF/BoQTPAK23OLGZ+OTk W620/2KUpkutM7+lBYU0IFDjVEgHAQlULhHPqtxKGB+WSllr7M3P6qU48m7q9Pcf+VVH 22FSvsNDjcmI56PoIXf3MHaGVQBu+GiU6mi/Mtu+aGfMNI9LWzs/DFcb+0GhJgJ4mCz5 JGv+pRUXNiTLoutjS3LafLpS3KTx/1iRe3l2kHHEHpnAssurXhL0fO7KuuQJfTDhOesd lEcw== 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=8kvn91wEby/GL05Cc0Dw1govFMsN7V4KtRge6QR8YGw=; b=Z5zD3pNomLQSpLdxen2Ev0eWmznBC++TyG2nS2vYKmp11Z1tWUK5c22KRl7syD5EDn DFSRLTJ/yxBE3d2buzL5yRJ6ECG4zdmhixTFPyxmrlvGShQ6ZxbFCm5zkWYPvZ2gohSF w/oTHFFDEy5Yes1YhqmQPtinpK4SEpZ1oP36e9Xh9z5ScII5Wq073oZotmGB3amU4xkV rdwHen6nlHVmFBci8mmqZXil+SfFkkP6hgbLNVnNmAbRrVILNt+Ws+TMsJRIlOH/TCBs nIrFodGIyrFobj+WlTXd0gnMY9zDibvoULvjJEUYf/sY5amSAviSIHA+ZD36nbVXju8H N1sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RwyK17s5; 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 t13-20020a056402524d00b0042dd10d4e9dsi10015717edd.508.2022.06.13.06.08.28; Mon, 13 Jun 2022 06:08:54 -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=RwyK17s5; 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 S244033AbiFMKZ6 (ORCPT + 99 others); Mon, 13 Jun 2022 06:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244999AbiFMKYV (ORCPT ); Mon, 13 Jun 2022 06:24:21 -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 CE4E1DF00; Mon, 13 Jun 2022 03:18:33 -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 87E41B80E5C; Mon, 13 Jun 2022 10:18:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03B9AC34114; Mon, 13 Jun 2022 10:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115511; bh=9yN++CsMDVfl9JvBg2aqRDLVDC8lQlieByJB/xWyZmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RwyK17s5Xf0nNDrWyqONotUS8mKY+0NALpqarmsqXY+m9G6YrYNN1mm3CWN5gdE4G pL2YIVqVgAOvpDh7Z04TdfSYU8LpX8wJ0Gn1vD9V0KLvHh+NjPFxK4ZN+THPfkrYGP DAJiwc+w8gZcPQf/XPN0d7h2/rB9OhbD+gWwjXtQ= 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.9 102/167] gma500: fix an incorrect NULL check on list iterator Date: Mon, 13 Jun 2022 12:09:36 +0200 Message-Id: <20220613094904.690195421@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 @@ -548,14 +548,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)