[U-Boot] [PATCH][v0] e1000_initialize: memset 0x0 nic and hw structure before their use
Prabhakar
prabhakar at freescale.com
Thu Nov 11 05:57:11 CET 2010
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: Prabhakar <prabhakar at freescale.com>
---
e1000_initialize: memset 0x0 nic and hw structure before their use
- Space left after sizeof is for the uniformity of this file
drivers/net/e1000.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 2825342..6f88012 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5177,7 +5177,19 @@ e1000_initialize(bd_t * bis)
}
nic = (struct eth_device *) malloc(sizeof (*nic));
+ if (nic)
+ memset(nic, 0, sizeof (*nic));
+ else
+ return 0;
+
hw = (struct e1000_hw *) malloc(sizeof (*hw));
+ if (hw)
+ memset(hw, 0, sizeof (*hw));
+ else {
+ free(nic);
+ return 0;
+ }
+
hw->pdev = devno;
nic->priv = hw;
--
1.6.3.1
More information about the U-Boot
mailing list