From: Kumar Gala Date: Fri, 12 Nov 2010 10:13:06 +0000 (-0600) Subject: net: e1000: Add initialized eth_device & e1000_hw structure X-Git-Tag: v2010.12-rc2~68 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4b29bdb0ed08412d225a8be94f61fc6c37a59dd5;p=u-boot net: e1000: Add initialized eth_device & e1000_hw structure nic and hw structures are allocated via malloc i.e. return memory is not zero initialized. Because of this few structure member like "function pointers" are initialized with garbage values. It may cause problem. for eg. during eth_initialize, dev->write_hwaddr is used. Signed-off-by: Kumar Gala Fixed typo. Signed-off-by: Wolfgang Denk --- diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 2825342ff5..18584efdd5 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -5177,7 +5177,21 @@ e1000_initialize(bd_t * bis) } nic = (struct eth_device *) malloc(sizeof (*nic)); + if (!nic) { + printf("Error: e1000 - Can not alloc memory\n"); + return 0; + } + hw = (struct e1000_hw *) malloc(sizeof (*hw)); + if (!hw) { + free(nic); + printf("Error: e1000 - Can not alloc memory\n"); + return 0; + } + + memset(nic, 0, sizeof(*dev)); + memset(hw, 0, sizeof(*hw)); + hw->pdev = devno; nic->priv = hw;