All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure
@ 2010-11-12 10:13 Kumar Gala
  2010-11-12 17:59 ` Paul Gortmaker
  2010-11-14 22:24 ` Wolfgang Denk
  0 siblings, 2 replies; 6+ messages in thread
From: Kumar Gala @ 2010-11-12 10:13 UTC (permalink / raw)
  To: u-boot

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 <galak@kernel.crashing.org>
---
 drivers/net/e1000.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 2825342..911eb2c 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 (!nic) {
+			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;
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure
  2010-11-12 10:13 [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure Kumar Gala
@ 2010-11-12 17:59 ` Paul Gortmaker
  2010-11-14 22:24 ` Wolfgang Denk
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 2010-11-12 17:59 UTC (permalink / raw)
  To: u-boot

On Fri, Nov 12, 2010 at 5:13 AM, Kumar Gala <galak@kernel.crashing.org> 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.
>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> ?drivers/net/e1000.c | ? 14 ++++++++++++++
> ?1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
> index 2825342..911eb2c 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 (!nic) {

Copy and paste error, I think you want "if (!hw)"

Paul.

> + ? ? ? ? ? ? ? ? ? ? ? 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;
>
> --
> 1.7.2.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure
  2010-11-12 10:13 [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure Kumar Gala
  2010-11-12 17:59 ` Paul Gortmaker
@ 2010-11-14 22:24 ` Wolfgang Denk
  2010-11-15 15:10   ` Kumar Gala
  1 sibling, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2010-11-14 22:24 UTC (permalink / raw)
  To: u-boot

Dear Kumar Gala,

In message <1289556786-15201-1-git-send-email-galak@kernel.crashing.org> 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.
> 
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
>  drivers/net/e1000.c |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
> index 2825342..911eb2c 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 (!nic) {
--------------------^^^^  !hw

Applied after fixing the typo.

Thanks.

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: wd at denx.de
The more complex the mind, the greater the need for the simplicity of
play.
	-- Kirk, "Shore Leave", stardate 3025.8

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure
  2010-11-14 22:24 ` Wolfgang Denk
@ 2010-11-15 15:10   ` Kumar Gala
  2010-11-16  0:02     ` [U-Boot] [PATCH] net: e1000: typo using wrong argument to sizeof Matthew McClintock
  0 siblings, 1 reply; 6+ messages in thread
From: Kumar Gala @ 2010-11-15 15:10 UTC (permalink / raw)
  To: u-boot


On Nov 14, 2010, at 4:24 PM, Wolfgang Denk wrote:

> Dear Kumar Gala,
> 
> In message <1289556786-15201-1-git-send-email-galak@kernel.crashing.org> 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.
>> 
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>> ---
>> drivers/net/e1000.c |   14 ++++++++++++++
>> 1 files changed, 14 insertions(+), 0 deletions(-)
>> 
>> diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
>> index 2825342..911eb2c 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 (!nic) {
> --------------------^^^^  !hw
> 
> Applied after fixing the typo.

Thanks ;)

- k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] net: e1000: typo using wrong argument to sizeof
  2010-11-15 15:10   ` Kumar Gala
@ 2010-11-16  0:02     ` Matthew McClintock
  2010-11-17 21:05       ` Wolfgang Denk
  0 siblings, 1 reply; 6+ messages in thread
From: Matthew McClintock @ 2010-11-16  0:02 UTC (permalink / raw)
  To: u-boot

Typo from 4b29bdb0ed08412d225a8be94f61fc6c37a59dd5

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
 drivers/net/e1000.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 18584ef..60b04c2 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5189,7 +5189,7 @@ e1000_initialize(bd_t * bis)
 			return 0;
 		}
 
-		memset(nic, 0, sizeof(*dev));
+		memset(nic, 0, sizeof(*nic));
 		memset(hw, 0, sizeof(*hw));
 
 		hw->pdev = devno;
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] net: e1000: typo using wrong argument to sizeof
  2010-11-16  0:02     ` [U-Boot] [PATCH] net: e1000: typo using wrong argument to sizeof Matthew McClintock
@ 2010-11-17 21:05       ` Wolfgang Denk
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2010-11-17 21:05 UTC (permalink / raw)
  To: u-boot

Dear Matthew McClintock,

In message <1289865773-10922-1-git-send-email-msm@freescale.com> you wrote:
> Typo from 4b29bdb0ed08412d225a8be94f61fc6c37a59dd5
> 
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> ---
>  drivers/net/e1000.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

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: wd at denx.de
"A child is a person who can't understand why someone would give away
a perfectly good kitten."                               - Doug Larson

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-11-17 21:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-12 10:13 [U-Boot] [PATCH] net: e1000: Add initialized eth_device & e1000_hw structure Kumar Gala
2010-11-12 17:59 ` Paul Gortmaker
2010-11-14 22:24 ` Wolfgang Denk
2010-11-15 15:10   ` Kumar Gala
2010-11-16  0:02     ` [U-Boot] [PATCH] net: e1000: typo using wrong argument to sizeof Matthew McClintock
2010-11-17 21:05       ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.