From patchwork Wed Apr 10 03:36:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang yuantian X-Patchwork-Id: 235288 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id C4E372C01DE for ; Wed, 10 Apr 2013 14:17:21 +1000 (EST) Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe006.messaging.microsoft.com [216.32.181.186]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 08A722C00BA; Wed, 10 Apr 2013 14:16:31 +1000 (EST) Received: from mail212-ch1-R.bigfish.com (10.43.68.246) by CH1EHSOBE020.bigfish.com (10.43.70.77) with Microsoft SMTP Server id 14.1.225.23; Wed, 10 Apr 2013 04:16:26 +0000 Received: from mail212-ch1 (localhost [127.0.0.1]) by mail212-ch1-R.bigfish.com (Postfix) with ESMTP id 53F5F30024C; Wed, 10 Apr 2013 04:16:26 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h1fc6h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1155h) Received: from mail212-ch1 (localhost.localdomain [127.0.0.1]) by mail212-ch1 (MessageSwitch) id 1365567385569954_4824; Wed, 10 Apr 2013 04:16:25 +0000 (UTC) Received: from CH1EHSMHS008.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.244]) by mail212-ch1.bigfish.com (Postfix) with ESMTP id 87E71E001D; Wed, 10 Apr 2013 04:16:25 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS008.bigfish.com (10.43.70.8) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 10 Apr 2013 04:16:19 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.328.11; Wed, 10 Apr 2013 04:16:18 +0000 Received: from rock.am.freescale.net (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r3A4GDpA015791; Tue, 9 Apr 2013 21:16:14 -0700 From: To: Subject: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args() Date: Wed, 10 Apr 2013 11:36:39 +0800 Message-ID: <1365564999-24427-1-git-send-email-Yuantian.Tang@freescale.com> X-Mailer: git-send-email 1.8.0 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: Tang Yuantian , devicetree-discuss@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, rob.herring@calxeda.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Tang Yuantian Call of_node_put() only when the out_args is NULL on success, or the node's reference count will not be correct because the caller will call of_node_put() again. Signed-off-by: Tang Yuantian --- v2: - modified the title and description. the 1st patch title is: of: remove the unnecessary of_node_put for of_parse_phandle_with_args() the 1st patch is not good enough. drivers/of/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 321d3ef..ee94f64 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1158,6 +1158,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np, if (!phandle) goto err; + /* Found it! return success */ if (out_args) { int i; if (WARN_ON(count > MAX_PHANDLE_ARGS)) @@ -1166,11 +1167,10 @@ static int __of_parse_phandle_with_args(const struct device_node *np, out_args->args_count = count; for (i = 0; i < count; i++) out_args->args[i] = be32_to_cpup(list++); + } else if (node) { + of_node_put(node); } - /* Found it! return success */ - if (node) - of_node_put(node); return 0; }