From patchwork Tue Dec 2 13:45:18 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Palix X-Patchwork-Id: 11850 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 94AF7DE329 for ; Wed, 3 Dec 2008 09:20:36 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org X-Greylist: delayed 629 seconds by postgrey-1.31 at ozlabs; Wed, 03 Dec 2008 00:45:24 EST Received: from mgw1.diku.dk (mgw1.diku.dk [130.225.96.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mgw1.diku.dk", Issuer "KU Security Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B6E67DDDE6 for ; Wed, 3 Dec 2008 00:45:24 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 94ECF52C3B8; Tue, 2 Dec 2008 14:45:19 +0100 (CET) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l5ZmdoEFHavk; Tue, 2 Dec 2008 14:45:17 +0100 (CET) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id BE6EE52C332; Tue, 2 Dec 2008 14:45:17 +0100 (CET) Received: from ip6-localhost (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id B0E896DF8C8; Tue, 2 Dec 2008 14:45:11 +0100 (CET) From: Nicolas Palix To: paulus@samba.org, benh@kernel.crashing.org Subject: [PATCH linux-next] powerpc/powermac: Add missing of_node_put Date: Tue, 2 Dec 2008 14:45:18 +0100 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200812021445.18670.npalix@diku.dk> X-Mailman-Approved-At: Wed, 03 Dec 2008 09:19:17 +1100 Cc: linuxppc-dev@ozlabs.org, Julia Lawall , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Palix X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org of_node_put is needed before discarding a value received from of_find_node_by_name, eg in error handling code or when the device node is no longer used. The semantic match that catches the bug is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression struct device_node *n; position p1, p2; struct device_node *n1; statement S; identifier f; expression E; expression *ptr != NULL; @@ n@p1 = of_find_node_by_name(...) ... if (!n) S ... when != of_node_put(n) when != n1 = f(n,...) when != E = n when any when strict ( return \(0\|<+...n...+>\|ptr\); | return@p2 ...; | of_node_put(n); | n1 = f(n,...) | E = n ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s of_find_node_by_name %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // Signed-off-by: Nicolas Palix Signed-off-by: Julia Lawall --- arch/powerpc/platforms/powermac/pci.c | 2 ++ arch/powerpc/platforms/powermac/time.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c index bcf50d7..800fcce 100644 --- a/arch/powerpc/platforms/powermac/pci.c +++ b/arch/powerpc/platforms/powermac/pci.c @@ -661,6 +661,7 @@ static void __init init_second_ohare(void) pci_find_hose_for_OF_device(np); if (!hose) { printk(KERN_ERR "Can't find PCI hose for OHare2 !\n"); + of_node_put(np); return; } early_read_config_word(hose, bus, devfn, PCI_COMMAND, &cmd); @@ -669,6 +670,7 @@ static void __init init_second_ohare(void) early_write_config_word(hose, bus, devfn, PCI_COMMAND, cmd); } has_second_ohare = 1; + of_node_put(np); } /* diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index 59eb840..394593c 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c @@ -265,12 +265,14 @@ int __init via_calibrate_decr(void) struct resource rsrc; vias = of_find_node_by_name(NULL, "via-cuda"); if (vias == 0) vias = of_find_node_by_name(NULL, "via-pmu"); if (vias == 0) vias = of_find_node_by_name(NULL, "via"); if (vias == 0 || of_address_to_resource(vias, 0, &rsrc)) return 0; + of_node_put(vias); + via = ioremap(rsrc.start, rsrc.end - rsrc.start + 1); if (via == NULL) { printk(KERN_ERR "Failed to map VIA for timer calibration !\n"); @@ -297,7 +299,7 @@ int __init via_calibrate_decr(void) ppc_tb_freq = (dstart - dend) * 100 / 6; iounmap(via); - + return 1; } #endif