public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Possible memory leak in cpu/ppc4xx/4xx_enet.c
Date: Mon, 17 Mar 2008 09:56:01 +0100	[thread overview]
Message-ID: <200803170956.01571.sr@denx.de> (raw)
In-Reply-To: <47DBE76D.9040706@verizon.net>

On Saturday 15 March 2008, Dave Littell wrote:
> >> I looked around this message and it seems that ppc_4xx_eth_initialize()
> >> malloc()?s a EMAC_4XX_HW_PST structure and assigns it to dev->priv.
> >> However, nothing ever frees this buffer so standing on a ping will
> >> ultimately pull down all the available memory.
> >
> > Hmmm. IIRC ppc_4xx_eth_initialize() is only called once upon bootup for
> > ethernet driver initialization. The function called each time before
> > network action is ppc_4xx_eth_init().
>
> It looks like ppc_4xx_eth_initialize() is called from eth_init() and
> ppc_4xx_eth_init() is only called if there's an emac0_dev.
>
> Hm?

I see. You don't have CONFIG_NET_MULTI defined. Which 4xx platform are we 
talking about btw?

> >> One fix might be to free( dev->priv ) at the end of ppc_4xx_eth_halt().
> >>  I tried this today and noted no ill effects.
> >
> > So did it work for you?
>
> It seems to be working well.

OK. But your patch will most likely break all platforms with CONFIG_NET_MULTI 
defined. Please give the attached patch a try and let me know if it works 
too. I'll push it online if it fixes the problem.

diff --git a/cpu/ppc4xx/4xx_enet.c b/cpu/ppc4xx/4xx_enet.c
index d990250..479cb40 100644
--- a/cpu/ppc4xx/4xx_enet.c
+++ b/cpu/ppc4xx/4xx_enet.c
@@ -1998,9 +1998,12 @@ int ppc_4xx_eth_initialize (bd_t * bis)
 }

 #if !defined(CONFIG_NET_MULTI)
-void eth_halt (void) {
+void eth_halt (void)
+{
        if (emac0_dev) {
                ppc_4xx_eth_halt(emac0_dev);
+               if (emac0_dev->priv)
+                       free(emac0_dev->priv);
                free(emac0_dev);
                emac0_dev = NULL;
        }


Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

  reply	other threads:[~2008-03-17  8:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-15  2:44 [U-Boot-Users] Possible memory leak in cpu/ppc4xx/4xx_enet.c Dave Littell
2008-03-15  6:07 ` Stefan Roese
2008-03-15 15:12   ` Dave Littell
2008-03-17  8:56     ` Stefan Roese [this message]
2008-03-17 23:10       ` Dave Littell

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=200803170956.01571.sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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