Dear Prabhakar,

In message <1289451431-22179-1-git-send-email-prabha...@freescale.com> you 
wrote:
> 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.

thanks. I already have a patch series "Add initialized eth_device
structure" on my stack.  I think this covers this, too.

>               nic = (struct eth_device *) malloc(sizeof (*nic));
> +             if (nic)
> +                     memset(nic, 0, sizeof (*nic));
> +             else
> +                     return 0;

Please don't write code like that.  Why would the memset() [and only
this, none of the following code whch is in the same logioc branch?]
be in the if() branch?

Write instead:

        nic = (struct eth_device *) malloc(sizeof (*nic));
        if (!nic) {
                issue error message
                return error code
        }

        memset();
        ...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Our missions are peaceful -- not for conquest.  When we do battle, it
is only because we have no choice.
        -- Kirk, "The Squire of Gothos", stardate 2124.5
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to