From patchwork Mon Aug 26 11:36:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 2849557 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 59E2ABF546 for ; Mon, 26 Aug 2013 11:58:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60E37202CC for ; Mon, 26 Aug 2013 11:58:30 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1504A202C8 for ; Mon, 26 Aug 2013 11:58:29 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VDvBN-00088S-CG; Mon, 26 Aug 2013 11:42:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VDvAa-0004cs-PS; Mon, 26 Aug 2013 11:41:16 +0000 Received: from na3sys009aog135.obsmtp.com ([74.125.149.84]) by merlin.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VDv9a-0004Uf-6n for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2013 11:40:16 +0000 Received: from SC-OWA01.marvell.com ([199.233.58.136]) (using TLSv1) by na3sys009aob135.postini.com ([74.125.148.12]) with SMTP ID DSNKUhs+gH6uIvLDlq9jF49vXDvvQLeTG+f4@postini.com; Mon, 26 Aug 2013 04:40:14 PDT Received: from maili.marvell.com (10.93.76.43) by sc-owa01.marvell.com (10.93.76.21) with Microsoft SMTP Server id 8.3.213.0; Mon, 26 Aug 2013 04:38:43 -0700 Received: from xhacker.marvell.com (unknown [10.37.135.179]) by maili.marvell.com (Postfix) with ESMTP id B6EAD1CCD9C; Mon, 26 Aug 2013 04:38:41 -0700 (PDT) From: Jisheng Zhang To: , , , , , , , , Subject: [PATCH v4 2/3] bus: mvebu: add missing of_node_put() to fix reference leak Date: Mon, 26 Aug 2013 19:36:57 +0800 Message-ID: <1377517018-7716-3-git-send-email-jszhang@marvell.com> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1377517018-7716-1-git-send-email-jszhang@marvell.com> References: <1377517018-7716-1-git-send-email-jszhang@marvell.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130826_074014_481670_6AD76D66 X-CRM114-Status: GOOD ( 10.73 ) X-Spam-Score: -4.2 (----) Cc: linux@arm.linux.org.uk, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add of_node_put to properly decrement the refcount when we are done using a given node. Signed-off-by: Jisheng Zhang Reviewed-by: Ezequiel Garcia --- drivers/bus/mvebu-mbus.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 19ab6ff..a7c12fb 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c @@ -701,6 +701,7 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus, size_t sdramwins_size) { int win; + struct device_node *np; mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size); if (!mbus->mbuswins_base) @@ -712,8 +713,11 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus, return -ENOMEM; } - if (of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric")) + np = of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric"); + if (np) { mbus->hw_io_coherency = 1; + of_node_put(np); + } for (win = 0; win < mbus->soc->num_wins; win++) mvebu_mbus_disable_window(mbus, win); @@ -902,23 +906,27 @@ int __init mvebu_mbus_dt_init(void) prop = of_get_property(np, "controller", NULL); if (!prop) { pr_err("required 'controller' property missing\n"); - return -EINVAL; + ret = -EINVAL; + goto np_out; } controller = of_find_node_by_phandle(be32_to_cpup(prop)); if (!controller) { pr_err("could not find an 'mbus-controller' node\n"); - return -ENODEV; + ret = -ENODEV; + goto np_out; } if (of_address_to_resource(controller, 0, &mbuswins_res)) { pr_err("cannot get MBUS register address\n"); - return -EINVAL; + ret = -EINVAL; + goto phandle_out; } if (of_address_to_resource(controller, 1, &sdramwins_res)) { pr_err("cannot get SDRAM register address\n"); - return -EINVAL; + ret = -EINVAL; + goto phandle_out; } /* Get optional pcie-{mem,io}-aperture properties */ @@ -931,9 +939,14 @@ int __init mvebu_mbus_dt_init(void) sdramwins_res.start, resource_size(&sdramwins_res)); if (ret) - return ret; + goto phandle_out; /* Setup statically declared windows in the DT */ - return mbus_dt_setup(&mbus_state, np); + ret = mbus_dt_setup(&mbus_state, np); +phandle_out: + of_node_put(controller); +np_out: + of_node_put(np); + return ret; } #endif