From patchwork Sat Oct 22 07:24:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1098285wrr; Sat, 22 Oct 2022 01:10:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5E4LduIYTe0yCQ8uq25CFtfG3xFbEOnMrGzuEDXUBVxFUcGuQV2tlRksi08cc9FjrRXx3Q X-Received: by 2002:a17:902:e9c2:b0:186:79dc:7d87 with SMTP id 2-20020a170902e9c200b0018679dc7d87mr6825307plk.59.1666426218810; Sat, 22 Oct 2022 01:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426218; cv=none; d=google.com; s=arc-20160816; b=QDfPCmfLY50VZaeU89xicJrFg/3fNgFoktP+tch7pcIt9NABrvBMb7LOfTrhDD3vML +JAQlTqsdJzFSXyM/whMMFCzTac1LGdZ0aet3t4Wgf+S2iYALoARCqvf6Haio4ZB9I4O AL0QuZ3l/kYBFfiLkE/UbR65z/MBHUS2iW/M463y3HUshs8b64I9esMC2IbL/u0QmkSS lgdURYwTiegtYFi7i4wLNiYEKomypFKEafHuUG/O19qfNXN9ZNR8T5U9EI0wPyoO4Pzs OAdlPphk8J5aoOT2cD/+sbIPAAY+kZyUKRSzQNeJx15a77Kk2Z5m2XBSOGBMzTHMi9Wx 2miQ== 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=Rf/z2BcpTI5GCxCgBMrQKzBRp6yRkDc5RfdSgE7iQCi9TOIOn3cJetZ5YjCAi54Lvr mNyIX2slifFtJxlJluP2NPdiYVYr+GVLtrEqUqMy2tpvfbeXVZGPNkEXZX41HGlp7OyW Q6V6QlHhuR+jt+tPLyE61oGNK5aIyibYozSjfdD6ietDgt7FAvdGXFkX5HdeX9B0uZfy 3/q78TB3aXbUkfPdWWVZM4nlR9r9RzFiPtMyp2aRyMQR+PnemJutmkVGmpO4Mlj3D0kU CFAVQMrKPFOTqGo2v3HNhk0rYgssxiTyAayjJ3Q+gIPGfBFK778jUGY0scgQDvfw0L90 L5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YTFDb4nO; 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 b14-20020a170902b60e00b00176a2d5ae14si25803174pls.363.2022.10.22.01.10.05; Sat, 22 Oct 2022 01:10:18 -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=YTFDb4nO; 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 S233159AbiJVIJF (ORCPT + 99 others); Sat, 22 Oct 2022 04:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233098AbiJVIEv (ORCPT ); Sat, 22 Oct 2022 04:04:51 -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 783142CE633; Sat, 22 Oct 2022 00:52:18 -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 9E54AB80E44; Sat, 22 Oct 2022 07:51:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5B06C433D6; Sat, 22 Oct 2022 07:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425088; bh=aMhgMqMGgRl1+zscEHQn3kdfGb1OaQRYRmBXmXDblFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YTFDb4nOOQRNILVx/vm2FgjCu9M6NnRqPxszTVTBivvxeIQcEk4HaEFD2oGciY1YE AADJOEyfXjRDw6DRFvrhN9IfB4nuJ5sFtrn80vqxTrKKTrX8t+lY+F7vEolB08RQ1c H10eBEJlxpAcljIanrrFlsknD6KA9t6GziEvhPwM= 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 385/717] clk: berlin: Add of_node_put() for of_get_parent() Date: Sat, 22 Oct 2022 09:24:24 +0200 Message-Id: <20221022072514.593575782@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?1747374538586833667?= X-GMAIL-MSGID: =?utf-8?q?1747374538586833667?= 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);