From patchwork Sat Oct 22 07:26:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1104866wrr; Sat, 22 Oct 2022 01:33:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6eVo74NJf5co5hAESnTnAELb2zEjs1CgkL8UrC/QJa3Je1FyxFruVc9UV3x6QmVhl0IdQP X-Received: by 2002:a05:6a00:1349:b0:563:654d:ce3f with SMTP id k9-20020a056a00134900b00563654dce3fmr23594486pfu.32.1666427613290; Sat, 22 Oct 2022 01:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427613; cv=none; d=google.com; s=arc-20160816; b=M/2MviU49YpzUkZkSEHtoEPdL1vsLUYyl/7h0eiXbbidSkK98gGhUvu4iplZOjrKWT /FXKHldJhSAEkZFhkQ3MQLKV0a8H98J+q8ahBsbwWHu6PuBHBN0qtIaqfrvNUQu0PKKL YDtOsJ6lMFrU1Uqpsg12UU1u2Si3dxLAHntbls97FJ73Vf1N1R0rC+obq+Z6qJMxwBP/ kOjQzdn9Y8e/Ra5EoAaXS3F21Tf2pEfCVqX//El+g6X6Rx0YIO5o9SEOAmztULmEtaSy zdXogfGdOoQA6BIXydcGAouA4g8cE4Vk+FgmeieoPRRBJ7x4uQGgY1JOmkBlzjxFOmS+ 29Mw== 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=Evmka1oQuAdiwcaxKLxtYpkMWiSxXEFjiOYfNW/PMQQ=; b=xsZ3TAUOTK8FK0+JynaJBqDZa1ZH0lU4gLq8CZzwMoy0n+q5kSCu1imo0qFAegTlct 4pJXFACCTsKhiK5MHx5GkdvNnoAKt2Fssondl9ZxrDbGblJyIgvqNjntxRKpd7aFKCXb GD1cNkIBNb1mg/npgnDyCZyu2Q+lWa4DC5pMykYQYxp8DKMe4ha8gsQ//ur2KSmOm2Lo q/2NeWrWvWH6KiX0o/rmdIep0SLmP6ciJIUtq5TAloKuv3Z3ophx8UIeZk3rUh2aV6zR 6pdkXBWs8WcneCmcIfwRh+brPhEv6HfQPALs7n4lw6iSllg/EzIcSJEkvPyS2SDEwMJy J9JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hUz/ueP2"; 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 l22-20020a056a0016d600b0052c56cea553si27764746pfc.352.2022.10.22.01.33.20; Sat, 22 Oct 2022 01:33:33 -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="hUz/ueP2"; 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 S233587AbiJVISb (ORCPT + 99 others); Sat, 22 Oct 2022 04:18:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234074AbiJVIQH (ORCPT ); Sat, 22 Oct 2022 04:16:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E571E2CCA13; Sat, 22 Oct 2022 00:57:01 -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 BBC0860AC3; Sat, 22 Oct 2022 07:56:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3E10C4314C; Sat, 22 Oct 2022 07:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425396; bh=kEJlBh+wNtWmXqcwtAkfwDO8V/HHGFV5VPH8ZyBTNso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUz/ueP2GksGPlESuPnNTjCY8clEMmKdQe6VFcTyMecW2kkgYPzpCrQt752yk5gby j51Z4E39aIlotQA033GHfpEOrszkRbABHjhQlWxDElpWzeobDmGB32bi8QGEDLkZkn fuFiM3beNsEiIYnttIYOz+M40Ua7Ng4pUjlfaE2o= 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 5.19 486/717] clk: ti: Balance of_node_get() calls for of_find_node_by_name() Date: Sat, 22 Oct 2022 09:26:05 +0200 Message-Id: <20221022072519.859940424@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.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 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?1747376001185929402?= X-GMAIL-MSGID: =?utf-8?q?1747376001185929402?= 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 121d8610beb1..6b2de32ef88d 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -148,11 +148,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);