From: vishwanath.bs@ti.com (Vishwanath Sripathy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: mach-omap2: smartreflex: fix another memory leak
Date: Mon, 7 Feb 2011 18:51:31 +0530 [thread overview]
Message-ID: <08d006ebf1b90e7b4804ab34d79a7585@mail.gmail.com> (raw)
In-Reply-To: <1297083471-6341-1-git-send-email-aaro.koskinen@nokia.com>
> -----Original Message-----
> From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm-
> kernel-bounces at lists.infradead.org] On Behalf Of Aaro Koskinen
> Sent: Monday, February 07, 2011 6:28 PM
> To: tony at atomide.com; linux-omap at vger.kernel.org; linux-arm-
> kernel at lists.infradead.org
> Cc: Aaro Koskinen
> Subject: [PATCH] arm: mach-omap2: smartreflex: fix another memory
> leak
>
> Temporary strings with volt_* file names should be released after the
> debugfs entries are created.
>
> The patch eliminates kmemleak reports with the following stack trace
> (multiple objects depending on HW):
>
> unreferenced object 0xcedbc5a0 (size 64):
> comm "swapper", pid 1, jiffies 4294929375 (age 423.734s)
> hex dump (first 32 bytes):
> 76 6f 6c 74 5f 39 37 35 30 30 30 00 00 00 00 00 volt_975000.....
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace:
> [<c012fee0>] create_object+0x104/0x208
> [<c012dbc8>] kmem_cache_alloc_trace+0xf0/0x17c
> [<c0013f64>] omap_sr_probe+0x314/0x420
> [<c02a1724>] platform_drv_probe+0x18/0x1c
> [<c02a088c>] driver_probe_device+0xc8/0x188
> [<c02a09b4>] __driver_attach+0x68/0x8c
> [<c02a00ac>] bus_for_each_dev+0x44/0x74
> [<c029f9e0>] bus_add_driver+0xa0/0x228
> [<c02a0cac>] driver_register+0xa8/0x130
> [<c02a1b2c>] platform_driver_probe+0x18/0x8c
> [<c0013c1c>] sr_init+0x40/0x74
> [<c005a554>] do_one_initcall+0xc8/0x1a0
> [<c00084f4>] kernel_init+0x150/0x218
> [<c0065d64>] kernel_thread_exit+0x0/0x8
> [<ffffffff>] 0xffffffff
>
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> ---
> arch/arm/mach-omap2/smartreflex.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-
> omap2/smartreflex.c
> index 77ecebf..61aebed 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -942,6 +942,7 @@ static int __init omap_sr_probe(struct
> platform_device *pdev)
> strcat(name, volt_name);
> (void) debugfs_create_x32(name, S_IRUGO | S_IWUGO,
> nvalue_dir,
> &(sr_info->nvalue_table[i].nvalue));
> + kfree(name);
I feel there is no real need to allocate and free memory dynamically here
when the size allocated is constant. Rather I would propose to create an
array name of size NVALUE_NAME_LEN+1 and use it inside the loop.
Vishwa
> }
>
> return ret;
> --
> 1.5.6.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2011-02-07 13:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 12:57 [PATCH] arm: mach-omap2: smartreflex: fix another memory leak Aaro Koskinen
2011-02-07 13:21 ` Vishwanath Sripathy [this message]
2011-02-14 22:36 ` Kevin Hilman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08d006ebf1b90e7b4804ab34d79a7585@mail.gmail.com \
--to=vishwanath.bs@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).