Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1038343iog; Wed, 15 Jun 2022 19:08:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s3uoOw/EtDPsuTios5RqPbXQip5MsPsrbYKIHI/Xbbzo9J+FPqDCRYLrsBxWxFwEPOZNiR X-Received: by 2002:a17:90b:4a83:b0:1e6:4b34:b760 with SMTP id lp3-20020a17090b4a8300b001e64b34b760mr13418149pjb.114.1655345323783; Wed, 15 Jun 2022 19:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655345323; cv=none; d=google.com; s=arc-20160816; b=ZncgQOcwQ3ZC4zyXmd89V/TXGqCX3p5Q7MSjRtxaMyU+ccWXWFR827b16SmZAASuZ7 3TRYorOaJh4k0KKPoM/UyqHWNTK1wGDsjGGqgDSShIkUD+Lis5dM/2kXsoL+A3WdZJyg 2Chg9AW8ENTvzVOmQdlCt5EVKLwOjtHYYCpEm3MFTl+oSPHUv/9I6iDeYx5NHiuOWvUM G7bPnWsE6GrWKZs6gvoACcktHsqwODR7z2QjyIuBs7OmTs8BOEA4I5q6FzqAwoBkP49p QbPMYYAYrLiAMP/TGVIcym3+MldeXtx1ewuryuycscsMhD1x01HSbRGfR7tv88C0qhkw uCZA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3Atn7fZcqnvSgGIlwBuPlL0MZEzYhI5kcoueR1+mD/o=; b=ibMVTRApgtsV/l+1uXXBs6vep5J4PmKkj1mkuFb04fLA9AMlrawPTRJQbg9UNCXdOH 1i2qQI1Tq4Heh7RL8Yb6SyQV5ShNkmw5x6PH1tMLOzYNp03JMcgzRa14DcX5RfMni9nd Q0RrmETQ3SAROhvYedFtsFc+dyWkJrOkkIZBmcp6/pD76a1o8CfgkrWV+m63sUMGrdSy oKOwLcUCUH5Q1PjxRinZW7fKCVbW9ZDv4V2MJ29GJbUhS6r09YPmLUDjqSGbKDEUQS2X Tnd/D+02MmLdPUNFh3uWJP1QXr52U6vJAA8CiVHTBYcAeF0qjYYXHgfW88BIQ/whgb3l kqjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=nUI9OGAV; 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=126.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u38-20020a632366000000b003fcd6212317si684582pgm.304.2022.06.15.19.08.31; Wed, 15 Jun 2022 19:08:43 -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=@126.com header.s=s110527 header.b=nUI9OGAV; 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=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356172AbiFPCBt (ORCPT + 99 others); Wed, 15 Jun 2022 22:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244252AbiFPCBs (ORCPT ); Wed, 15 Jun 2022 22:01:48 -0400 Received: from mail-m963.mail.126.com (mail-m963.mail.126.com [123.126.96.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 797205933D for ; Wed, 15 Jun 2022 19:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=3Atn7 fZcqnvSgGIlwBuPlL0MZEzYhI5kcoueR1+mD/o=; b=nUI9OGAV7FLPRLIz8jaYc 9+LZ+XwiDZL7mv+zByXaU2bv1Sc/cMI5YbxCsAb+iBAiXz5Ciig/hHNIi+mxrhlt zwl/jzH4ZlNjYG2w3e2BtrgCiQh5Mn6S96EirAHYrQwgpZr9DRYwSJ6d6EZox5r8 T/IuYKXE6DAn+2mtqaddqs= Received: from localhost.localdomain (unknown [124.16.139.61]) by smtp8 (Coremail) with SMTP id NORpCgAX9loBj6piLpPcFg--.13778S2; Thu, 16 Jun 2022 10:01:39 +0800 (CST) From: Liang He To: pali@kernel.org, lpieralisi@kernel.org Cc: windhl@126.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] bus: (mvebu-mbus) Add missing of_node_put() Date: Thu, 16 Jun 2022 10:01:35 +0800 Message-Id: <20220616020135.3973141-1-windhl@126.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: NORpCgAX9loBj6piLpPcFg--.13778S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr18Cw4xAFy7uw48KrW3Jrb_yoW8ur18pa y7WrW3try0qr4fJFZayryfZFyakFn7WFWjqFsFkFnrAanxGry5Jry2kryrAF98AFW09w15 tr10ya1xWF9rAF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRoSotUUUUU= X-Originating-IP: [124.16.139.61] X-CM-SenderInfo: hzlqvxbo6rjloofrz/1tbiuAgiF2JVj4ze6AABsG X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 In mvebu_mbus_dt_init(), of_find_matching_node_and_match() and of_find_node_by_phandle() will both return node pointers with refcount incremented. We should use of_node_put() in fail path or when it is not used anymore. Signed-off-by: Liang He --- changelog: v2: (1) use real name (2) add of_node_put when not used anymore v1: add of_node_put in fail path drivers/bus/mvebu-mbus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index db612045616f..e168c8de2ae8 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c @@ -1327,22 +1327,28 @@ int __init mvebu_mbus_dt_init(bool is_coherent) prop = of_get_property(np, "controller", NULL); if (!prop) { + of_node_put(np); pr_err("required 'controller' property missing\n"); return -EINVAL; } controller = of_find_node_by_phandle(be32_to_cpup(prop)); if (!controller) { + of_node_put(np); pr_err("could not find an 'mbus-controller' node\n"); return -ENODEV; } if (of_address_to_resource(controller, 0, &mbuswins_res)) { + of_node_put(np); + of_node_put(controller); pr_err("cannot get MBUS register address\n"); return -EINVAL; } if (of_address_to_resource(controller, 1, &sdramwins_res)) { + of_node_put(np); + of_node_put(controller); pr_err("cannot get SDRAM register address\n"); return -EINVAL; } @@ -1360,6 +1366,8 @@ int __init mvebu_mbus_dt_init(bool is_coherent) pr_warn(FW_WARN "deprecated mbus-mvebu Device Tree, suspend/resume will not work\n"); } + of_node_put(controller); + mbus_state.hw_io_coherency = is_coherent; /* Get optional pcie-{mem,io}-aperture properties */ @@ -1378,6 +1386,11 @@ int __init mvebu_mbus_dt_init(bool is_coherent) return ret; /* Setup statically declared windows in the DT */ - return mbus_dt_setup(&mbus_state, np); + ret = mbus_dt_setup(&mbus_state, np); + + of_node_put(np); + + return ret; + } #endif -- 2.25.1