From patchwork Mon Oct 24 11:30:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp430314wru; Mon, 24 Oct 2022 05:41:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jOj9nLm4jd99GT1CzshMf5koIf3Dz0MNWx2wx62HCJrj9FMuxmvFyk0UV7FbR1ks/VKp5 X-Received: by 2002:a17:907:3d91:b0:78e:11cc:3bc7 with SMTP id he17-20020a1709073d9100b0078e11cc3bc7mr27557097ejc.655.1666615273866; Mon, 24 Oct 2022 05:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615273; cv=none; d=google.com; s=arc-20160816; b=JETfIqdzAoLI/looODLyjDG74xRsg6Yc6+9G8HFM0cfFQ+GrItJLVhvao8G0fkJY/D d2dqDhp5S6Sjk4BA4hAS3Y4KG0XfIHhaA2I5vN5q3g6dgYFrSQD88K1b3jCDQnE8qm4N ByflnWSGiQHH9rYDs0lesx+Lz3bYLX5AteLjnT5CNaLYp5MD9RTPTjvEKKqXedkx1LTa 92J3LHxqa6qt1e9NtDekJ23DR1bDTycLKTonyp32Hi8AeKAvR3L92N+suwNU5kwDtrpM xUqtDtIjMUm89H18FYVW8+Vg3EwWtr0Zsj+amiA/fk9zR3bJdoGBHc/YgyWvj1CeT9lO ZdIg== 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=bnS6BiI5il66Xexz0jy8Zd0CildFeJq+jLa/TMhcsSg=; b=CPDWIGt7NHyHc3shsB5vVDU7Fy2TVk1beHGnrKoQN9Hnqk08kpdty3bL8ZHESPAkqI o4DxIrZPx1ktfKBMGL6s8Z8qxCzfe6A7X3exqMO4EhPqkHO2fNIzNEO983agrFBjNYX7 lb1K4KYufEg2GX9YXap2KYMioyKHayC2ShfXvU9JuU3tSjqEJo6x1T5sc4xan7KDIfIz mZNHN9It8Vm9dFTwJNJORWkzv+yLtCZR+dosB8DuwTRKDLkidUXUSunE2JbWIpvVWEdl PiDpkf1EihwNQgdGpQx35tf6yRUKPTqpY7PC+AtEsLX4OfLvgDeEh2/jORanqOwRkZlQ OlDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bMTjAO+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 q26-20020a056402249a00b00461dfe5f99bsi1582662eda.298.2022.10.24.05.40.41; Mon, 24 Oct 2022 05:41: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=bMTjAO+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 S233817AbiJXM2U (ORCPT + 99 others); Mon, 24 Oct 2022 08:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiJXM1J (ORCPT ); Mon, 24 Oct 2022 08:27:09 -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 16470237E2; Mon, 24 Oct 2022 05:01: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 dfw.source.kernel.org (Postfix) with ESMTPS id 8415C612D2; Mon, 24 Oct 2022 12:01:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94550C433D6; Mon, 24 Oct 2022 12:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612877; bh=2JKLRDy2+cZZ2o+s2K3b+kNs0R+1VkWPx5B+2IXlEkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bMTjAO+nKBxeUEfypVxXfBsY9FpipfFhHx+F/85afysRH9kmloGeywmvQEHWQOqKw PCW18vUUCwUDm31y27R4408DiSVCVRWJSzuLqKAGfRk6e5T9sb6bwoqh3lvvoElNny D5wxeeEe2dJZaMnst3Qmu5ty6YnDnTDdm2BsEyYE= 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 4.19 122/229] clk: berlin: Add of_node_put() for of_get_parent() Date: Mon, 24 Oct 2022 13:30:41 +0200 Message-Id: <20221024113002.943563849@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747572777355056227?= X-GMAIL-MSGID: =?utf-8?q?1747572777355056227?= 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 0b4b44a2579e..6efc3e02da47 100644 --- a/drivers/clk/berlin/bg2.c +++ b/drivers/clk/berlin/bg2.c @@ -499,12 +499,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 9b9db743df25..5bcd8406ac93 100644 --- a/drivers/clk/berlin/bg2q.c +++ b/drivers/clk/berlin/bg2q.c @@ -285,19 +285,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);