From patchwork Mon Oct 24 11:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp435573wru; Mon, 24 Oct 2022 05:54:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XKRNnvVCWoIIRKQwqNRw5FaYnYpMa6GdFkqRn0bio4C0tORFL62abpXIYX8C/zZlJnqMJ X-Received: by 2002:a17:906:fc6:b0:72f:d080:416 with SMTP id c6-20020a1709060fc600b0072fd0800416mr27900006ejk.1.1666616090771; Mon, 24 Oct 2022 05:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616090; cv=none; d=google.com; s=arc-20160816; b=0YHBH2VdGS6VdfB7GBlUcvVsPwbeR2Q42d0kOKNqkLJOek+RJVmjgUq3ICpKKyry7E ztgV8dOHVQO5Y6Hb1nHXGsroq3oogtpRmnj64TL5EQKYM/Q3xtRdMBBjG7K2bOkOtFLQ vAZA0dyc/cPmZfTECAH8cm4pS/3VsbmKO8xnZiP6uJ3jowihibnza9qol2My0KS9gPk6 oV7kbJcwEpMWpLNw2bfgwMNrbszKaYKV22lya6K/AsL2WO2JcGQJ/YEjkUuySeT2qhKZ FZ0MiemCrrZBx1XZ4eq3BleK4mrXiXi+3/SsvDaJFFHzpLb2ClbebPp4cmQKFgcRHLvZ /BaQ== 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=eUkHvBttQaI6RxRBPfjIsjMYp6pz05z4rUI/rZUDaCc=; b=d3HatgjZAlSQJhFlS4hGhPM+ymOtB1KKML0uujeDhaQkY5DSOcAldALgVF00DleNC6 pjmGum86MAhYuTSMZVuT1rtK+t2lS0f5tp4gJ3llf/ipVLGyojwSoirYbFXGdzbG/SCW xetwbG07XRo8Wvk2sAF7DVJLtgXrEPmHVH2DVCQtJKFB0JPdVpEPao/0ta6SSJDg6P4m 7C4HwqYWe0sRmDwlT1ebs1a/33O9a3PD6nO3XxWB7vO2eCeotskXHrtuyIxpeGzPminw YfmUIAziaG8LR5TbTzCtQQsTMVvqNHQQqkZfY+sQjZX1tXV7XBwS8LVuZ7lL9X947WBP 9OVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vN4ATdDv; 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 p34-20020a056402502200b0045d45f0e69asi24470611eda.561.2022.10.24.05.54.26; Mon, 24 Oct 2022 05:54:50 -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=vN4ATdDv; 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 S234393AbiJXMwn (ORCPT + 99 others); Mon, 24 Oct 2022 08:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234632AbiJXMtL (ORCPT ); Mon, 24 Oct 2022 08:49:11 -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 54C6B923E4; Mon, 24 Oct 2022 05:13:04 -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 0426B61218; Mon, 24 Oct 2022 12:11:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12798C433C1; Mon, 24 Oct 2022 12:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613487; bh=aMhgMqMGgRl1+zscEHQn3kdfGb1OaQRYRmBXmXDblFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vN4ATdDvTkGOIHAHSnLjQRBZnL4rByEKNnsjf+qQncrHwv33Q5g/07YMygGB8ylNv E/9GrB+OyWmECrmv+N/giEbZe4kgZOXxK3p1TcIna5Z0umYBsb79qcDi6sa8Bvkk9G m/doXHboSqCBx2T9qWBATdFkXfg8iubFXQive9CU= 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.4 125/255] clk: berlin: Add of_node_put() for of_get_parent() Date: Mon, 24 Oct 2022 13:30:35 +0200 Message-Id: <20221024113006.715657901@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573634346091892?= X-GMAIL-MSGID: =?utf-8?q?1747573634346091892?= From: Liang He [ Upstream commit 37c381b812dcbfde9c3f1f3d3e75fdfc1b40d5bc ] In berlin2_clock_setup() and berlin2q_clock_setup(), we need to call of_node_put() for the reference returned by of_get_parent() which has increased the refcount. We should call *_put() in fail path or when it is not used anymore. Fixes: 26b3b6b959b2 ("clk: berlin: prepare simple-mfd conversion") Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220708084900.311684-1-windhl@126.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/berlin/bg2.c | 5 ++++- drivers/clk/berlin/bg2q.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/clk/berlin/bg2.c b/drivers/clk/berlin/bg2.c index bccdfa00fd37..67a9edbba29c 100644 --- a/drivers/clk/berlin/bg2.c +++ b/drivers/clk/berlin/bg2.c @@ -500,12 +500,15 @@ static void __init berlin2_clock_setup(struct device_node *np) int n, ret; clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL); - if (!clk_data) + if (!clk_data) { + of_node_put(parent_np); return; + } clk_data->num = MAX_CLKS; hws = clk_data->hws; gbase = of_iomap(parent_np, 0); + of_node_put(parent_np); if (!gbase) return; diff --git a/drivers/clk/berlin/bg2q.c b/drivers/clk/berlin/bg2q.c index e9518d35f262..dd2784bb75b6 100644 --- a/drivers/clk/berlin/bg2q.c +++ b/drivers/clk/berlin/bg2q.c @@ -286,19 +286,23 @@ static void __init berlin2q_clock_setup(struct device_node *np) int n, ret; clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL); - if (!clk_data) + if (!clk_data) { + of_node_put(parent_np); return; + } clk_data->num = MAX_CLKS; hws = clk_data->hws; gbase = of_iomap(parent_np, 0); if (!gbase) { + of_node_put(parent_np); pr_err("%pOF: Unable to map global base\n", np); return; } /* BG2Q CPU PLL is not part of global registers */ cpupll_base = of_iomap(parent_np, 1); + of_node_put(parent_np); if (!cpupll_base) { pr_err("%pOF: Unable to map cpupll base\n", np); iounmap(gbase);