From: Prabhakar Date: Thu, 11 Nov 2010 10:27:11 +0530 Subject: [U-Boot] [PATCH][v0] e1000_initialize: memset 0x0 nic and hw structure before their use Message-ID: <1289451431-22179-1-git-send-email-prabhakar@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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