Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3166785pxb; Mon, 18 Apr 2022 17:53:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRdc+CLGhA4Pl8TgwOxlIsVMieUwxBSFB9ELp3rLHU3RvEgzsXgSC5pzggQWCMszBoFhq5 X-Received: by 2002:a63:1e05:0:b0:39d:adee:a8a1 with SMTP id e5-20020a631e05000000b0039dadeea8a1mr12209397pge.412.1650329583757; Mon, 18 Apr 2022 17:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650329583; cv=none; d=google.com; s=arc-20160816; b=020rx01Pnuac5pG/q2NSjLnhQYGblBniN2JVN746UsSjodv0oEXoMVEkLS1Y+Iw1ht Efx4Hk20yZIOTiPgu71GDaiUpDo2g7NyRslGtvklunoUdAsW2iAq+hNwbrr4lMDG0pX3 Lx2bpVCZwJJFTO4/n/mzvgh15LQvb2SL7xzIpU7l/OOPRDa+tdR+z2R04+ORc6KP8BC7 lQF1wTROTEqSUf5eoiXg4LFKKuMjG+DLPS2NFsfVriu7VWPj+HztW8P7NgvlwR55cN0j 5Edi0IrC0QeYfoIFy1gz2HGsqMng/UIvO4jjBO4blMiMLRNdqB1jCNnmYRWoRfuYZPbb VBGQ== 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=TBJn5nnC1UOiBlvacyh+PvE5agmuWp9246NaihKj29Y=; b=eQbD1hCQ8fkD4h4chnUSg9q7zF2IBJX+Swn16MVmytyGvx1VG6qsRiqepFnxtl+Ljj IugG6r41FUADexizy0A/tZMAu3/g8B979zdrS3mCn/0SQoOsn/DbbD8lMxV4BviR4JR9 d1u4t3EHIOL7pAbcAeCFGWaMZvsgFi2UN+BBGlhJuafNyDkx3gxzB3j718YXIbJanKEg eRA8h3HoYfPduR3umcLSPm2FZKARNUBhjJpRwhWLtVZr5j3qZH9J686M9mlgRu6HH+9q 7kjJYD5I5FCOIzg+dSQB8UaWTqQ7wytWrAT4zrupw7bpNXdjHC+e0J9uK1J5rst9n0F5 fizQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y3m6topk; 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 s10-20020a63ff4a000000b003aa339f83b7si737794pgk.310.2022.04.18.17.52.47; Mon, 18 Apr 2022 17:53:03 -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=y3m6topk; 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 S244703AbiDRN5f (ORCPT + 99 others); Mon, 18 Apr 2022 09:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242054AbiDRN1a (ORCPT ); Mon, 18 Apr 2022 09:27:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC583E5FD; Mon, 18 Apr 2022 05:53:13 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 2D88F612B5; Mon, 18 Apr 2022 12:53:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04D0AC385A1; Mon, 18 Apr 2022 12:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286391; bh=HTDpf9gOSoN+0VRBjXQ2P84SInQ0QONH+i4WXzJpWGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y3m6topkf2htaAvHIano2vK79WPIm/pLAGE7bkWNEIsKh4BINXD8Hvqfnl0CsZD1U HRkCWo9oKu10g6kNxBzHlHB31RO54l7ODL6CcuavxLXwTWZKtvaPnVgcJSrQL5CKQ/ 1E3v8a+TlCho/y++MVtnxRGyJbXPVBAJcpNClk5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakob Koschel , Michael Ellerman , Sasha Levin Subject: [PATCH 4.14 119/284] powerpc/sysdev: fix incorrect use to determine if list is empty Date: Mon, 18 Apr 2022 14:11:40 +0200 Message-Id: <20220418121214.476001943@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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=-7.7 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: Jakob Koschel [ Upstream commit fa1321b11bd01752f5be2415e74a0e1a7c378262 ] 'gtm' will *always* be set by list_for_each_entry(). It is incorrect to assume that the iterator value will be NULL if the list is empty. Instead of checking the pointer it should be checked if the list is empty. Fixes: 83ff9dcf375c ("powerpc/sysdev: implement FSL GTM support") Signed-off-by: Jakob Koschel Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220228142434.576226-1-jakobkoschel@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/sysdev/fsl_gtm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c index d902306f4718..42fe959f6fc2 100644 --- a/arch/powerpc/sysdev/fsl_gtm.c +++ b/arch/powerpc/sysdev/fsl_gtm.c @@ -90,7 +90,7 @@ static LIST_HEAD(gtms); */ struct gtm_timer *gtm_get_timer16(void) { - struct gtm *gtm = NULL; + struct gtm *gtm; int i; list_for_each_entry(gtm, >ms, list_node) { @@ -107,7 +107,7 @@ struct gtm_timer *gtm_get_timer16(void) spin_unlock_irq(>m->lock); } - if (gtm) + if (!list_empty(>ms)) return ERR_PTR(-EBUSY); return ERR_PTR(-ENODEV); } -- 2.34.1