From patchwork Wed Feb 10 12:28:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Koskinen, Aaro (Nokia - FI/Espoo)" X-Patchwork-Id: 78418 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1ACSLDr025782 for ; Wed, 10 Feb 2010 12:28:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755696Ab0BJM2U (ORCPT ); Wed, 10 Feb 2010 07:28:20 -0500 Received: from smtp.nokia.com ([192.100.122.233]:29623 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755219Ab0BJM2U (ORCPT ); Wed, 10 Feb 2010 07:28:20 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o1ACS1NY026873; Wed, 10 Feb 2010 14:28:14 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 10 Feb 2010 14:28:05 +0200 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 10 Feb 2010 14:28:05 +0200 Received: from esdhcp040169.research.nokia.com (esdhcp040169.research.nokia.com [172.21.40.169]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o1ACS087004996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 10 Feb 2010 14:28:02 +0200 Date: Wed, 10 Feb 2010 14:28:00 +0200 (EET) From: Aaro Koskinen X-X-Sender: aakoskin@ak-desktop To: ext Tony Lindgren cc: "Koskinen Aaro (Nokia-D/Helsinki)" , "linux-omap@vger.kernel.org" , "Hunter Adrian (Nokia-D/Helsinki)" , "Lavinen Jarkko (Nokia-D/Helsinki)" Subject: Re: [PATCH] OMAP: hsmmc: fix memory leak In-Reply-To: <20100209231732.GM21755@atomide.com> Message-ID: References: <1265632385-27448-1-git-send-email-aaro.koskinen@nokia.com> <20100209231732.GM21755@atomide.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-OriginalArrivalTime: 10 Feb 2010 12:28:05.0752 (UTC) FILETIME=[7EF23780:01CAAA4C] X-Nokia-AV: Clean 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.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Feb 2010 12:28:22 +0000 (UTC) From 6d15f48ecc177bde18033af2884eb2c5ce53bfd7 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Thu, 4 Feb 2010 13:06:59 +0200 Subject: [PATCH] OMAP: hsmmc: fix memory leak The platform data allocated with kmalloc() will become unreachable once the init is complete, so it should be freed. The problem was discovered by kmemleak. Signed-off-by: Aaro Koskinen --- arch/arm/mach-omap2/mmc-twl4030.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-omap2/mmc-twl4030.c b/arch/arm/mach-omap2/mmc-twl4030.c index 0c3c72d..8afe9dd 100644 --- a/arch/arm/mach-omap2/mmc-twl4030.c +++ b/arch/arm/mach-omap2/mmc-twl4030.c @@ -408,6 +408,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers) { struct twl4030_hsmmc_info *c; int nr_hsmmc = ARRAY_SIZE(hsmmc_data); + int i; if (cpu_is_omap2430()) { control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE; @@ -434,7 +435,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers) mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); if (!mmc) { pr_err("Cannot allocate memory for mmc device!\n"); - return; + goto done; } if (c->name) @@ -532,6 +533,10 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers) continue; c->dev = mmc->dev; } + +done: + for (i = 0; i < nr_hsmmc; i++) + kfree(hsmmc_data[i]); } #endif -- 1.5.6.5