From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Wed, 24 Mar 2010 03:51:50 -0400 Subject: [U-Boot] [PATCH] net: add altera triple speeds ethernet mac driver In-Reply-To: <1269412366-9206-1-git-send-email-thomas@wytron.com.tw> References: <1269412366-9206-1-git-send-email-thomas@wytron.com.tw> Message-ID: <201003240351.51649.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wednesday 24 March 2010 02:32:46 Thomas Chou wrote: > +int altera_tse_init(bd_t *bis, int num_tses) so "num_tses" is the # of devices to allocate ... > + return 1; ... but you always return 1. this should probably be num_tses. > + for (num = 0; num < num_tses; num++) { > + dev = (struct eth_device *)malloc(sizeof *dev); > + > + if (NULL == dev) > + return 0; > + > + memset(dev, 0, sizeof *dev); > + > + priv = (struct altera_tse_priv *)malloc(sizeof(*priv)); malloc returns (void *), so i dont think you need the casts > + if (NULL == priv) > + return 0; this leaks the memory given to dev when there's an error > + if (NULL == rx_desc || NULL == tx_desc) > + return 0; an error here should probably free the current dev/priv structures > + /* Tell u-boot to get the addr from the env */ > + for (i = 0; i < 6; i++) > + dev->enetaddr[i] = 0; you called memset() on *dev already, so this explicit enetaddr init is not needed > --- /dev/null > +++ b/include/altera_tse.h this should probably live alongside the driver rather than in include/ -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20100324/650128c6/attachment.pgp