From patchwork Sat Oct 22 07:24:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1121088wrr; Sat, 22 Oct 2022 02:27:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5X24gEIZ0NoaY32pvC8FWX9zJlDHv1tyR8RcKu9PWm71EbZerC66rlq63h8lSfuQPtqKjH X-Received: by 2002:a05:6a00:174a:b0:562:781f:eca3 with SMTP id j10-20020a056a00174a00b00562781feca3mr23080931pfc.41.1666430847295; Sat, 22 Oct 2022 02:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430847; cv=none; d=google.com; s=arc-20160816; b=Jim4DQZt/NcYq2PwNT9GyzB+TnoqlN034ODVKHh2o5HGYOr+G9F4TEab8r7yd7LypC cKsOJ6ZBJX//FNfjXvb2mMh8AjPZ+QOtehu++H43dIo1Up5aOij9knCWAasHFmt/e3VQ /LRkOeL91XVB25T2+/WU7tBKG8CG6B1OHYQoZUm9XsiKvJqIhwJq8ar/5N0uHUoicxgk M/f8DCV1NqRn6lcpn8a1lO8gl9RwD2uyr/xjTdAp+aAQpS49ZPbkaH2rfzEzZD+SLqVI UnWxOf9UUFMtVFutRlnRe9+1UAwFVffyu3DDc3E/TDGTP35rG48iVl5Q90l/8w70F6eY yrAQ== 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=MK5VI+3GBq8LdKsjE6o7xvZVfSAcQ8o/y+v9hNNFJts=; b=0TtvD6FuKgXxFU8rPPsvq2aSkHricUdBk6zdchu2MmYAXaUgVqAOL8qv2v4il2ZSpD /5CGdrEh4jPW1tRxBhKD1pTsJT0IufhqXVwiFmpeD22j101Ms/nqd9MnbBWQEahyuKDN hJ0E4cFjY662MSM7/7UfOolwmuvCJLdOTDkmOlCcinm/XVJzkQU3wkiitOsYePFPjPVj TId8Qymw6AtwOzcoiM7RZMFjVxB5YK5q/fGtFYPukhrbV1noNYIqHZvepoaoTYxNng1f DkK8ZujmLWh/oJKvYZ8NcXSDTODnQYZg6tZ8yh3WXj8THqvamWvVcRnBDa6ZmIvN3VC9 m5CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JxzKIfy4; 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 d18-20020a170902ced200b001865dfb6774si11670600plg.458.2022.10.22.02.27.14; Sat, 22 Oct 2022 02:27:27 -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=JxzKIfy4; 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 S233577AbiJVJFa (ORCPT + 99 others); Sat, 22 Oct 2022 05:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235139AbiJVJDy (ORCPT ); Sat, 22 Oct 2022 05:03:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3623A2FACFB; Sat, 22 Oct 2022 01:19: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 dfw.source.kernel.org (Postfix) with ESMTPS id 489CD60ADB; Sat, 22 Oct 2022 07:51:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5341BC433D7; Sat, 22 Oct 2022 07:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425078; bh=mgfxMUrqtSlUZHIjEaaKuLvZ8O/qKzLSst2rHPmyHgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxzKIfy4NFP9DHHg8O1lEK05g8c0KaxCxFZoCIatyGYsGxlyWZwzFEn+lHNTYtDiu SWg62ZBYbGGsbi1psTRqxAC6qudfT0uiPXXtZj6zTAqFQAppPolIoywFPReeRn1+4L KJ3GR8J5/dQRGB4/Dmct1neLooWYfEs+xscjnvJA= 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 382/717] clk: st: Hold reference returned by of_get_parent() Date: Sat, 22 Oct 2022 09:24:21 +0200 Message-Id: <20221022072514.301189135@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?1747379392231498828?= X-GMAIL-MSGID: =?utf-8?q?1747379392231498828?= From: Liang He [ Upstream commit 429973306f860470cbbb8402c8c53143b450faba ] We should hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance. Fixes: 3efe64ef5186 ("clk: st: clkgen-fsyn: search reg within node or parent") Fixes: 810251b0d36a ("clk: st: clkgen-mux: search reg within node or parent") Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220628142416.169808-1-windhl@126.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/st/clkgen-fsyn.c | 5 ++++- drivers/clk/st/clkgen-mux.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c index 582a22c04919..d820292a381d 100644 --- a/drivers/clk/st/clkgen-fsyn.c +++ b/drivers/clk/st/clkgen-fsyn.c @@ -987,6 +987,7 @@ static void __init st_of_quadfs_setup(struct device_node *np, const char *pll_name, *clk_parent_name; void __iomem *reg; spinlock_t *lock; + struct device_node *parent_np; /* * First check for reg property within the node to keep backward @@ -994,7 +995,9 @@ static void __init st_of_quadfs_setup(struct device_node *np, */ reg = of_iomap(np, 0); if (!reg) { - reg = of_iomap(of_get_parent(np), 0); + parent_np = of_get_parent(np); + reg = of_iomap(parent_np, 0); + of_node_put(parent_np); if (!reg) { pr_err("%s: Failed to get base address\n", __func__); return; diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c index ee39af7a0b72..596e939ad905 100644 --- a/drivers/clk/st/clkgen-mux.c +++ b/drivers/clk/st/clkgen-mux.c @@ -56,6 +56,7 @@ static void __init st_of_clkgen_mux_setup(struct device_node *np, void __iomem *reg; const char **parents; int num_parents = 0; + struct device_node *parent_np; /* * First check for reg property within the node to keep backward @@ -63,7 +64,9 @@ static void __init st_of_clkgen_mux_setup(struct device_node *np, */ reg = of_iomap(np, 0); if (!reg) { - reg = of_iomap(of_get_parent(np), 0); + parent_np = of_get_parent(np); + reg = of_iomap(parent_np, 0); + of_node_put(parent_np); if (!reg) { pr_err("%s: Failed to get base address\n", __func__); return;