Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4050682rwi; Sat, 22 Oct 2022 04:28:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tMpGQ54s7tko0J4CZ9hg4UbtUXgmMUudnhXBuW4GSUX7NZBCfT2jPelbA6+8YOh4Wi+5L X-Received: by 2002:a17:903:246:b0:179:b6d0:f8fd with SMTP id j6-20020a170903024600b00179b6d0f8fdmr23861688plh.124.1666438126329; Sat, 22 Oct 2022 04:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666438126; cv=none; d=google.com; s=arc-20160816; b=f7tJEBQkPZA4+oXdjDmOKl53xeWnYxMBW1Hz8rep/xpBcgEvoTvcJB+JoW9PxfeM4S 137M+CKtkULhugymh1GkosVBMsZilt4IMzqYN9ihougOoBW2SGm5SyBRQvbxUmRaH8+i dInk3UEtHppmS10W+ynRJTdBvzCG2hqlv9ODwoebnGcL9rRbXZvHaNPsgazvna13rdQ5 hQwy/b0NWWBMARR4TzL1fl6PJ1V5zOudhYU8H1wm+B1cfpwOj04lOa9/5kUu7lvxOU5n 1JqBmV4iFd6vgDUOCgQzQL678q5ADcmXu+VsTO201eCAPFhr0qJf/qzxgSjF83wqupRg 4WzQ== 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=vv2kkTlwi827bhesaXPo4NxUMR49MnouQx1PAxQ8JRtoPAdvvH9ydTB/2YYFObFhXA dvQZhzlJhWMwxiH4xOpLxz+N+OGLgj63SI3y9Dyg/fYptQAInm1wfBYH2g0shhWO1BJs McuJYtJshr7DON6kf8jRY9lu+8usOgRIc7U/N5gPfli8M7bInknu3QoIuchh0oTA7S1O EFDgSPRT86o9Reo8zDFz2LUYec2TEc1ci5OuEI1T+xHEH4/ez5KlkDzkCK7TsZRtYR11 l4RoANM9s03GkCBRRJFXjG/a17dmTNldOyk12HG4UVjUYjyC8q7tkzmR6Oehf0gOxY0y BbLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WQjIPg+n; 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 b4-20020a170902d50400b0017f83500442si30244410plg.491.2022.10.22.04.28.34; Sat, 22 Oct 2022 04:28:46 -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=WQjIPg+n; 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 S230520AbiJVLDW (ORCPT + 99 others); Sat, 22 Oct 2022 07:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbiJVLCl (ORCPT ); Sat, 22 Oct 2022 07:02:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 003D22FACEA; Sat, 22 Oct 2022 03:21: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 ams.source.kernel.org (Postfix) with ESMTPS id A8E4DB82E0E; Sat, 22 Oct 2022 07:51:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECF21C433D6; Sat, 22 Oct 2022 07:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425091; bh=I0US6l38rqGsDxa7m8QNmS8D7lDmiOG+/urZP2mhyxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WQjIPg+nVcMy+f+EIpot44TI4IhwhdxxzSE7/LsDJJOx0uyOkpLCAPDojeCXmG+rq Pq0T2Xyau0W1YqH0j8FmUpSy1Z5KFzjPOyRicFV78y7aIyIyC4UmfEksX6dYVRggG2 SEH2bOl3eJRdkwMbvPvkA4fWH4mPVLLTW3GlXiiE= 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.19 386/717] clk: sprd: Hold reference returned by of_get_parent() Date: Sat, 22 Oct 2022 09:24:25 +0200 Message-Id: <20221022072514.654609744@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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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); -- 2.35.1