From patchwork Fri May 13 16:46:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 783532 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4DGkchl009439 for ; Fri, 13 May 2011 16:46:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759619Ab1EMQqR (ORCPT ); Fri, 13 May 2011 12:46:17 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:56944 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759198Ab1EMQqO (ORCPT ); Fri, 13 May 2011 12:46:14 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id 8027E19BC9D; Fri, 13 May 2011 18:46:13 +0200 (CEST) Received: from mgw2.diku.dk ([127.0.0.1]) by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08611-08; Fri, 13 May 2011 18:46:10 +0200 (CEST) Received: from palace.topps.diku.dk (palace.ekstranet.diku.dk [192.38.115.202]) by mgw2.diku.dk (Postfix) with ESMTP id 29CA819BC91; Fri, 13 May 2011 18:46:10 +0200 (CEST) From: Julia Lawall To: Tony Lindgren Cc: kernel-janitors@vger.kernel.org, Russell King , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arch/arm/mach-omap1/dma.c: Invert calls to platform_device_put and platform_device_del Date: Fri, 13 May 2011 18:46:10 +0200 Message-Id: <1305305170-16922-1-git-send-email-julia@diku.dk> X-Mailer: git-send-email 1.7.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 13 May 2011 16:46:38 +0000 (UTC) From: Julia Lawall Platform_device_del should be called before platform_device_put, as platform_device_put can delete the structure. Additionally, improve the error handling code for the call to ioremap, so that it calls platform_device_put. The semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @@ expression e1,e2; @@ *platform_device_put(e1); ... when != e1 = e2 *platform_device_del(e1); // Signed-off-by: Julia Lawall --- Is an ioremap needed also? Not clear, because dma_base i a global variable. arch/arm/mach-omap1/dma.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c index d855934..f5a5220 100644 --- a/arch/arm/mach-omap1/dma.c +++ b/arch/arm/mach-omap1/dma.c @@ -284,14 +284,15 @@ static int __init omap1_system_dma_init(void) dma_base = ioremap(res[0].start, resource_size(&res[0])); if (!dma_base) { pr_err("%s: Unable to ioremap\n", __func__); - return -ENODEV; + ret = -ENODEV; + goto exit_device_put; } ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res)); if (ret) { dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", __func__, pdev->name, pdev->id); - goto exit_device_del; + goto exit_device_put; } p = kzalloc(sizeof(struct omap_system_dma_plat_info), GFP_KERNEL); @@ -299,7 +300,7 @@ static int __init omap1_system_dma_init(void) dev_err(&pdev->dev, "%s: Unable to allocate 'p' for %s\n", __func__, pdev->name); ret = -ENOMEM; - goto exit_device_put; + goto exit_device_del; } d = kzalloc(sizeof(struct omap_dma_dev_attr), GFP_KERNEL); @@ -380,10 +381,10 @@ exit_release_d: kfree(d); exit_release_p: kfree(p); -exit_device_put: - platform_device_put(pdev); exit_device_del: platform_device_del(pdev); +exit_device_put: + platform_device_put(pdev); return ret; }