From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Hilman Subject: Re: [PM-SR][PATCH 1/2 v2] omap3: sr: fix memory leak and simplify the code Date: Tue, 24 Aug 2010 14:25:01 -0700 Message-ID: <87vd6zn1oy.fsf@deeprootsystems.com> References: <1278687874-26123-1-git-send-email-nm@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail-pv0-f174.google.com ([74.125.83.174]:58410 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755435Ab0HXVZF (ORCPT ); Tue, 24 Aug 2010 17:25:05 -0400 Received: by pvg2 with SMTP id 2so2799658pvg.19 for ; Tue, 24 Aug 2010 14:25:04 -0700 (PDT) In-Reply-To: <1278687874-26123-1-git-send-email-nm@ti.com> (Nishanth Menon's message of "Fri, 9 Jul 2010 10:04:34 -0500") Sender: linux-omap-owner@vger.kernel.org List-Id: linux-omap@vger.kernel.org To: Nishanth Menon , Thara Gopinath Cc: linux-omap , Artem Bityutskiy , Peter p2 De Schrijver Nishanth Menon writes: > From: Artem Bityutskiy > > This patch fixes the following problem indicated by kmemleak: > > kmemleak: unreferenced object 0xdf93c280 (size 64): > kmemleak: backtrace: > kmemleak: [] create_object+0x104/0x200 > kmemleak: [] kmem_cache_alloc+0xe4/0xf4 > kmemleak: [] omap_devinit_smartreflex+0x44/0x244 > kmemleak: [] do_one_initcall+0x5c/0x1b8 > kmemleak: [] kernel_init+0x94/0x110 > kmemleak: [] kernel_thread_exit+0x0/0x8 > > The reason is that 'omap_devinit_smartreflex()' allocates 'sr_data', > then passes it to 'omap_device_build()', which 'kmemdup()'s it and > uses the copy. But 'omap_devinit_smartreflex()' never frees 'sr_data'. > > This patch make 'sr_data' to be a stack variable, which eliminates > the memory leak and simplifies the code a bit. > > Cc: Kevin Hilman > Cc: Thara Gopinath , > Cc: Peter p2 De Schrijver > Cc: Nishanth Menon > > Signed-off-by: Artem Bityutskiy > Acked-by: Nishanth Menon > --- > Changes from V1: > rebased to latest pm-sr branch > default of sr_data set to 0 to make it equivalent to kzalloc > > NOTE: this probably should be squashed when being send upstream along with > rest of SR series Thara, you appear to have fixed this problem differently in your latest series. Looks like you just ensured kfree() was always done, correct? In the future, it would be helpful if you would reply to these proposed fixes on the list so we know if they are incorporated or handled differently. Thanks, Kevin