From patchwork Sat Oct 22 07:24:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1154069wrr; Sat, 22 Oct 2022 04:07:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47qt64bed7NZVMybuNFB4zb+dWBJQFDbiCI5haLtTQY2gWibxadhMEupWyjYCUqzbKu25e X-Received: by 2002:a17:907:a4e:b0:77d:94d:8148 with SMTP id be14-20020a1709070a4e00b0077d094d8148mr18873690ejc.607.1666436851855; Sat, 22 Oct 2022 04:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666436851; cv=none; d=google.com; s=arc-20160816; b=PO4JtcgN0muIYG/ZV4kOGncAdGubkIMQyGf8MU6ciR+UkT4Au/1qOlgYZ1hZ2CLrK0 Vov0nIz/4qPyAFL9nw1ZfdZZEiUfcAft2ueGYn8paj1aAIq/P0FeBp8jFM+9vDkAb7wR sAT308csBV+67pnWo09V/9LjNZrkqlm9Xlg7a5cGnbA47TcC8zov4IPyyAxVDLyxDTSM pkAMKWAIeBla1uYRA5LXkl8rYeQo5JaHIzb9t5/O6AoF/zopZTTw9pj1ugGgRUaKF7gY 7KKm+t0g6S+wakA4Jn06PLOkZg8kFJT8et9j6nlVG4lDrpcCFB1yoKqxiWAAaLDdAtye riRg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020aa7cb13000000b0045829a1c0b3si18445815edt.251.2022.10.22.04.07.06; Sat, 22 Oct 2022 04:07:31 -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 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?1747385688343836821?= X-GMAIL-MSGID: =?utf-8?q?1747385688343836821?= 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);