Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp903652rwi; Wed, 19 Oct 2022 04:33:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72F78GtJcDTXwfcw/8VTA/aayIMLI22rmELe81HBygZu4pDPsaznzu0kIVO0H759ewCCEv X-Received: by 2002:a05:6a00:851:b0:563:6c6a:2b7b with SMTP id q17-20020a056a00085100b005636c6a2b7bmr8092719pfk.45.1666179193943; Wed, 19 Oct 2022 04:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179193; cv=none; d=google.com; s=arc-20160816; b=GLNyecFquQCBkwIrd7EOHrVSKCSnVRsOmthyqyNPodjP2KruBvhNDQhX5zYq3qWY7K ls0bD6ihIZVeezOaqcvg0EmVt/xxqImjLuBso7ILCauGCg9w6GaEfA/ThtBxsdjcLheL boT8eoXEUKF1n0Qq4XVYkC/hbViNfWPC5MO1NH+D3SK1JI/YndteWwoKclST32uVwYZa Booytcrg3wthaggHlrpbqV5z1Kof4PGf6Iz2Y6eYn2oU6EpLygam7UbsxFqfFzAUKFaY KDB/hz42hrX0iC7ZcvG6cFnNTpl5ZcWfKws2Soz6VRd0ms9Vb3VCJPBzoD8KCZKOPn+G rmTg== 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=MG9cuf6q/yE/IadoTO3ZffK3BoFzgpLnwFRUI+jP9ag+n6qT2u1JNLKCZ1uMwEKF4L 8ZtaPFI4KGI67dR8e4nm6tOA/MaHJbGMgzXYMaePld4LRt0tDLnla1Sh/jZk2kb9Er4C KI22mDxKOFGcnm1EsqA8d6FRSwzROe/R8u1jUnzme35eTrGdG6cje8aOcnkavgLQVuHi Ke9my0jW07TpOwMR6jCp+moetoqTMZqfNci7nFQCFnnH/2pISa0Aa62FpTaG9hid4rgD kL5PZC8NlkPbtjcNYHh0BMwUAR9UYrZxUEXDLJSsduiFTYknhEv0svCSF7/RoJjAemqw K9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OerNXwzj; 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 f13-20020a056a001acd00b00536c198ca83si20160025pfv.15.2022.10.19.04.33.01; Wed, 19 Oct 2022 04:33:13 -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=OerNXwzj; 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 S234354AbiJSKsr (ORCPT + 99 others); Wed, 19 Oct 2022 06:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233412AbiJSKqp (ORCPT ); Wed, 19 Oct 2022 06:46:45 -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 40EC311F48B; Wed, 19 Oct 2022 03:21:38 -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 9F253B82440; Wed, 19 Oct 2022 08:59:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E29CC433C1; Wed, 19 Oct 2022 08:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169948; bh=mgfxMUrqtSlUZHIjEaaKuLvZ8O/qKzLSst2rHPmyHgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OerNXwzjif7td4HsVbOdtW9klXGaOhtdyMt40EkYj8JURINlew1rTajrh6Y15Iv9T wlWUsdsLly+Kxoh50TsqmtXlrwwl+0XmjcrwtjwBtsgL0L2+zRbzCqyuGWza87lPAY RLn73Cku1iSegNyryoIEaBKpmK/D5lpvTfkf4hD0= 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 6.0 469/862] clk: st: Hold reference returned by of_get_parent() Date: Wed, 19 Oct 2022 10:29:16 +0200 Message-Id: <20221019083310.695992944@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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 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; -- 2.35.1