From patchwork Wed Oct 19 08:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5134 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp251814wrs; Wed, 19 Oct 2022 03:52:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+Lh1qDHCoueSJiG5NcNEEO5AVbwDkW8ecpp7Ucef1As1LtmG8QEb/3xORzlsF06XAtyP3 X-Received: by 2002:a17:906:5dae:b0:78e:3109:36d1 with SMTP id n14-20020a1709065dae00b0078e310936d1mr6234045ejv.470.1666176764935; Wed, 19 Oct 2022 03:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176764; cv=none; d=google.com; s=arc-20160816; b=KRQVDaJ3KBPwKfKhZONfG5EDBgLJTUzAgbfUN5AkGrA1hzXe5v2hOoA+/CN0IZzqqs kGNGrnLr3pjHXmP9PX2OVeGkVmpbCTQH81IoOYm/mVWnhH1C76L9EU2hKrVazDICOcgP 8hYwR++35TfeB39hGDQ+e8EGAGKE58hF59lFUKvBpje0xFD7rkarj3prEEz9ZttqPMxz wA+RdBZs4gHWWNDc64kmijvO8Jp+kPxYbpMUNCBRvLxHb+pT2FTIQ9VrCnP3THlA3qHC UpTraWoK2KW+q6CDMnJuwJvyyVIBVWYgq4MLW1eHCqt8oZH+l2EA70kltkZwCfTzprAV 3e5w== 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=q0h0XGt1O0XQC/sZYtX1T9KrMxBfVGKvJh//q0BTOXfY1t+rZK1kzwkaXPxHT7qCbq wW8ga4PkpcMi6mCB41ELUCoWwIp6T0z2YyuqRaokN40lVtOQRsAlGVXaM6Tvf8/p1f55 mPSCEyd4MQ/F9KqYhzN+Xn4SIrHAlqGs9iax0zWfi81FXW7rVo7ay/BgKWL5vljiPKgV sGRrSNjV9GSx+34jBcKr29spRH3Wp35wvkB8eMs6pVjhJh81bEBPOzVEwT5pWiy3YIKH B54BB2SKDKUB5GhGzgIerfn1bUrzZ1YegwMl9gyITHpfJfbmIcRIvLwy6gGQgwBM9FVr AxfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KFOwIjuT; 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 dv1-20020a170906b80100b0073c14b6560bsi12536016ejb.177.2022.10.19.03.52.20; Wed, 19 Oct 2022 03:52:44 -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=KFOwIjuT; 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 S234470AbiJSKtK (ORCPT + 99 others); Wed, 19 Oct 2022 06:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233512AbiJSKrE (ORCPT ); Wed, 19 Oct 2022 06:47:04 -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 7CD12A6C1D; Wed, 19 Oct 2022 03:21:43 -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 C8F64B82443; Wed, 19 Oct 2022 08:59:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DD30C433D6; Wed, 19 Oct 2022 08:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169956; bh=aMhgMqMGgRl1+zscEHQn3kdfGb1OaQRYRmBXmXDblFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFOwIjuTKfgVtPU+CDIhcZexDqs9QTNfH79T5s+eelDTrY33bZWTIr+I7Oy2caTVM nQa7si5xwc2b1ZORTpKxyQ8c+QJEAbAeS/BWBJHqxECnLfwvN5TbaCPN3GBGS+z1oe u6uAm3T0fFChHVCDXDA/1CUFl4uN8pUqto+vfPPo= 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 472/862] clk: berlin: Add of_node_put() for of_get_parent() Date: Wed, 19 Oct 2022 10:29:19 +0200 Message-Id: <20221019083310.820792702@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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112967330496324?= X-GMAIL-MSGID: =?utf-8?q?1747112967330496324?= 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);