Patchwork [U-Boot,08/10,v2] net: pcnet: Add initialized eth_device structure

login
register
mail settings
Submitter Nobuhiro Iwamatsu
Date Oct. 19, 2010, 5:03 a.m.
Message ID <1287464627-12302-8-git-send-email-iwamatsu@nigauri.org>
Download mbox | patch
Permalink /patch/71879/
State Accepted
Commit 5ed0eeca388de64e3a7f2c1f0e5668704dab71c5
Headers show

Comments

Nobuhiro Iwamatsu - Oct. 19, 2010, 5:03 a.m.
pcnet driver does not have write_hwaddr function.
However, eth stuff executes write_hwaddr function
because eth_device structure has not been initialized.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
CC: Ben Warren <biggerbadderben@gmail.com>
---
 drivers/net/pcnet.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index 99b6942..e994cb6 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -187,6 +187,11 @@  int pcnet_initialize (bd_t * bis)
 		 * Allocate and pre-fill the device structure.
 		 */
 		dev = (struct eth_device *) malloc (sizeof *dev);
+		if (!dev) {
+			printf("pcnet: Can not allocate memory\n");
+			break;
+		}
+		memset(dev, 0, sizeof(*dev));
 		dev->priv = (void *) devbusfn;
 		sprintf (dev->name, "pcnet#%d", dev_nr);