From patchwork Mon Oct 24 11:29:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp534897wru; Mon, 24 Oct 2022 09:12:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VGmr2uKBDQu6jOHQykoE7Zx+qunjan+WqoZh+x8YVinw2ZhFMMMdoM8VyUbOO8L69PJ5V X-Received: by 2002:a17:902:bcc4:b0:181:899a:ac9c with SMTP id o4-20020a170902bcc400b00181899aac9cmr34173063pls.124.1666627920871; Mon, 24 Oct 2022 09:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627920; cv=none; d=google.com; s=arc-20160816; b=fZr2ZxKsBln7zOS0xa88f/kagr+F7tW/cR7R79qQ9FL7jWqaOhK38ggatZo/R5MaGV JA2tuWbMKomdgm9Nwe+YYI8fWxnqUiw8qcxmonwAiDy1774M1FWHqeNnMvYHQ8Og8p8C ilsGU1fiqDqhx/ELzs+X/ZxsIiURI0/7MSalGZXEJoDnUfX3+q361ppG4+8XmmfPxmZI 7zuiFu9mjQysI5JRA5lgvQNu5BSaa91m8PRYcgADc16UuYe0yeeANHyZ8nqDb51sTxZU iLj104XCRwaMTGssHQtGKDCuplFfgyULIGE2ficER96MfAE9AnaTASSeZG1K8FD1wdUP c1wQ== 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=4BIP7yCJkEfhe91Lk7KXrUGr2g1NopchynjnoQZ5RxI=; b=bb4QaJzihIOQQqmmGG3BL1ylBuK57+ZDXYSqYHZQp6WahS06pr2G0oUEdFR4od+8/s v0/zWtowThGmhU43Pb/6g5DQQEBY/Q1Jr1/P2pkmWKcguTXPtRt5+E6y/VCN+JLH+NuD HfCmKB7gUbi8NOjGg1WjMsJGyox8K+hJ0W/IqJhk7XzPHN48xIFmO8QLlak+S/RvquRa mZUMquSnO88OPVwaiZQPG9kY2OR128YNXdOsbvE4p4vRb2nl/ZqLZ1QJvQ2P2swiuHae NvOkXyZ3RkADlr+b316C64t6DJJey3ex98UxsYxWk68dmeWpVtnWzj904zIN9bWPKSM1 zFDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=19aNddWx; 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 n6-20020a654506000000b0044b817adee1si34651677pgq.78.2022.10.24.09.11.46; Mon, 24 Oct 2022 09:12: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=19aNddWx; 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 S233260AbiJXQKl (ORCPT + 99 others); Mon, 24 Oct 2022 12:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232803AbiJXQDZ (ORCPT ); Mon, 24 Oct 2022 12:03:25 -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 7775814030; Mon, 24 Oct 2022 07:56:06 -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 CB5C3B81670; Mon, 24 Oct 2022 12:24:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC1AC433D6; Mon, 24 Oct 2022 12:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614276; bh=I0US6l38rqGsDxa7m8QNmS8D7lDmiOG+/urZP2mhyxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=19aNddWxjDTkK+DCtGgp+KPgsSZdyRn+LiQfUlFg6XVgfslTj/MkGd14omW/xjTAw LHuSWeX6WXi/3utR+Sw5IdKmU0vr9Li7of4X0HBvgJ7wzO1516IWVWW8uyLIWfFOFo nsVXS5Jhqab5KEa8wmrJelNsltDA///M0WRLoeoQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Orson Zhai , Stephen Boyd , Sasha Levin Subject: [PATCH 5.10 200/390] clk: sprd: Hold reference returned by of_get_parent() Date: Mon, 24 Oct 2022 13:29:57 +0200 Message-Id: <20221024113031.292062805@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747586038412780992?= X-GMAIL-MSGID: =?utf-8?q?1747586038412780992?= From: Liang He [ Upstream commit 91e6455bf715fb1558a0bf8f645ec1c131254a3c ] We should hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance. Fixes: f95e8c7923d1 ("clk: sprd: support to get regmap from parent node") Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220704004729.272481-1-windhl@126.com Reviewed-by: Orson Zhai Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/sprd/common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c index d620bbbcdfc8..ce81e4087a8f 100644 --- a/drivers/clk/sprd/common.c +++ b/drivers/clk/sprd/common.c @@ -41,7 +41,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev, { void __iomem *base; struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; + struct device_node *node = dev->of_node, *np; struct regmap *regmap; if (of_find_property(node, "sprd,syscon", NULL)) { @@ -50,9 +50,10 @@ int sprd_clk_regmap_init(struct platform_device *pdev, pr_err("%s: failed to get syscon regmap\n", __func__); return PTR_ERR(regmap); } - } else if (of_device_is_compatible(of_get_parent(dev->of_node), - "syscon")) { - regmap = device_node_to_regmap(of_get_parent(dev->of_node)); + } else if (of_device_is_compatible(np = of_get_parent(node), "syscon") || + (of_node_put(np), 0)) { + regmap = device_node_to_regmap(np); + of_node_put(np); if (IS_ERR(regmap)) { dev_err(dev, "failed to get regmap from its parent.\n"); return PTR_ERR(regmap);