From patchwork Wed Oct 19 08:31:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp332870wrs; Wed, 19 Oct 2022 06:39:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Y7WlM0t1/s15kyfQp+UCeFvDsVJ8zVpUuQ+f3PqGChJiqSUe6OYmYy/TOxmOYtHqh3R7g X-Received: by 2002:a17:902:ec86:b0:185:483e:e4ec with SMTP id x6-20020a170902ec8600b00185483ee4ecmr8590806plg.164.1666186784664; Wed, 19 Oct 2022 06:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186784; cv=none; d=google.com; s=arc-20160816; b=ggCKp7OZndFGEjrJD8ZTT1NIV8uyjTTnEgnOspH2EOA1861PdGKub6+OYcXFncbt37 scBfmr9uBH9+5EAaAOXghJvlAYmP8lDKDjpI7Utt2MVHTTMrGVXNhplEXi2aCP8N+nJu a5YpnA5Uo47UOL1QswZPiV2kNidBNJVCz5O1ZIftCFnWpCj7zclER1LlR5ay60RA4Z/5 fDvKXt3+qQZCjHmS4ZGFBHS2HuhfS1gC/ayRU2fQWeHiYWIVgeTUIAX8+/hGZuGmI72U 7w3EBYR77AghlEHGl1uHvZOJC2NGDx5tGUrOSPeQ955m/t0IeG/kvjjqBS0LeqmpRCAs KkrQ== 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=IMvrzPZDe6S/Bf4yzcrbTxTXznzTydPcp//lfajMluA=; b=U2z8w+ikFn8Vs6S++nDa+Ph4agB7lcQbQXYTFIRr9+XmWvbvI4pOa36kShLlFxrYMp 05FqARVbmLTUioCnsVab+CvefSfkF7RdvmW2SnIpnJgNddRGVcoNiZm9jLoqsC/wnQzl mkbQNid+v4ueUEWI0brE50SrzMesPbDauabd3S+QgwzmlxTZbO0BS1+63UNeXi8Ptnqj CW3eAJLSlbhSm+DKqxHSHyh1BS9Qz7xRUKeRwQNqifrVbLJuVAE9O+RZGn0DuaMXokcU xrvfmo2eScUR7tXl95uxKk+wtFvg4DU7SW9/Yk/wN4kzXZyrPYwCaIBBVsCKBMZFTXfA 5MBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g1xvTNu8; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a170902b70800b00179f72a057esi17240729pls.417.2022.10.19.06.39.29; Wed, 19 Oct 2022 06:39:44 -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=g1xvTNu8; 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 S232008AbiJSNgk (ORCPT + 99 others); Wed, 19 Oct 2022 09:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbiJSNgF (ORCPT ); Wed, 19 Oct 2022 09:36:05 -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 AA986157893; Wed, 19 Oct 2022 06:25:11 -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 C4780B8247F; Wed, 19 Oct 2022 09:05:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25215C433C1; Wed, 19 Oct 2022 09:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170309; bh=aKUcsa7cZlsRyIMxZGGQkgloTdCqdrQaEUZAYX/1P7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1xvTNu8Q0csK+KPQjvKrBVPoL9DAKq/DTa3sa5WeR5f6r2DCM41VGeLY7R0Df1W/ ZLFbPoz4wBo9qzhF/rVm3pmYAjvRHT9yCRf+PPxsOOPdbfECplCYR0YZjXhrMdKM7r isgMU52NPj6h0orYd9S2fvSGtuanoUo6DUr1olwo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Stephen Boyd , Sasha Levin Subject: [PATCH 6.0 599/862] clk: ti: Balance of_node_get() calls for of_find_node_by_name() Date: Wed, 19 Oct 2022 10:31:26 +0200 Message-Id: <20221019083316.424482657@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123473542204172?= X-GMAIL-MSGID: =?utf-8?q?1747123473542204172?= From: Liang He [ Upstream commit 058a3996b888ab60eb1857fb4fd28f1b89a9a95a ] In ti_find_clock_provider(), of_find_node_by_name() will call of_node_put() for the 'from' argument, possibly putting the node one too many times. Let's maintain the of_node_get() from the previous search and only put when we're exiting the function early. This should avoid a misbalanced reference count on the node. Fixes: 51f661ef9a10 ("clk: ti: Add ti_find_clock_provider() to use clock-output-names") Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220915031121.4003589-1-windhl@126.com [sboyd@kernel.org: Rewrite commit text, maintain reference instead of get again] Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/ti/clk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 373e9438b57a..1dc2f15fb75b 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -140,11 +140,12 @@ static struct device_node *ti_find_clock_provider(struct device_node *from, break; } } - of_node_put(from); kfree(tmp); - if (found) + if (found) { + of_node_put(from); return np; + } /* Fall back to using old node name base provider name */ return of_find_node_by_name(from, name);