All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] net: Check network device driver name
@ 2011-08-30  9:30 Michal Simek
  2011-09-01 14:12 ` Mike Frysinger
  2011-09-04 21:29 ` Wolfgang Denk
  0 siblings, 2 replies; 4+ messages in thread
From: Michal Simek @ 2011-08-30  9:30 UTC (permalink / raw)
  To: u-boot

If name is longer than allocated space NAMESIZE
mac address is rewritten which show error
message like:

Error message:
Warning: Xlltemac.87000000 MAC addresses don't match:
Address in SROM is         30:00:00:00:00:00
Address in environment is  00:0a:35:00:6a:04

NAMESIZE contains Driver name + zero terminated character.

Signed-off-by: Michal Simek <monstr@monstr.eu>

---
v2: Apply Mike Frysinger version
---
 net/eth.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index a34fe59..c9b7e85 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -224,6 +224,14 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 int eth_register(struct eth_device *dev)
 {
 	struct eth_device *d;
+
+	size_t len = strlen(dev->name);
+	if (len >= NAMESIZE) {
+		printf("Network driver name is too long (%zu >= %zu): %s\n",
+						len, NAMESIZE, dev->name);
+		return -1;
+	}
+
 	if (!eth_devices) {
 		eth_current = eth_devices = dev;
 		eth_current_changed();
-- 
1.5.5.6

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

* [U-Boot] [PATCH v2] net: Check network device driver name
  2011-08-30  9:30 [U-Boot] [PATCH v2] net: Check network device driver name Michal Simek
@ 2011-09-01 14:12 ` Mike Frysinger
  2011-09-02  9:27   ` Michal Simek
  2011-09-04 21:29 ` Wolfgang Denk
  1 sibling, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2011-09-01 14:12 UTC (permalink / raw)
  To: u-boot

On Tuesday, August 30, 2011 05:30:13 Michal Simek wrote:
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -224,6 +224,14 @@ int eth_write_hwaddr(struct eth_device *dev, const
> char *base_name, int eth_register(struct eth_device *dev)
>  {
>  	struct eth_device *d;
> +
> +	size_t len = strlen(dev->name);
> +	if (len >= NAMESIZE) {
> +		printf("Network driver name is too long (%zu >= %zu): %s\n",
> +						len, NAMESIZE, dev->name);
> +		return -1;
> +	}

thinking a little more, i wonder if this wouldnt be better as an assert() or 
BUG_ON().  this isnt a normal issue and generally gets caught once -- during 
development of a new board.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110901/7c75798a/attachment.pgp 

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

* [U-Boot] [PATCH v2] net: Check network device driver name
  2011-09-01 14:12 ` Mike Frysinger
@ 2011-09-02  9:27   ` Michal Simek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2011-09-02  9:27 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Tuesday, August 30, 2011 05:30:13 Michal Simek wrote:
>> --- a/net/eth.c
>> +++ b/net/eth.c
>> @@ -224,6 +224,14 @@ int eth_write_hwaddr(struct eth_device *dev, const
>> char *base_name, int eth_register(struct eth_device *dev)
>>  {
>>  	struct eth_device *d;
>> +
>> +	size_t len = strlen(dev->name);
>> +	if (len >= NAMESIZE) {
>> +		printf("Network driver name is too long (%zu >= %zu): %s\n",
>> +						len, NAMESIZE, dev->name);
>> +		return -1;
>> +	}
> 
> thinking a little more, i wonder if this wouldnt be better as an assert() or 
> BUG_ON().  this isnt a normal issue and generally gets caught once -- during 
> development of a new board.

Just during development. Not sure if possible to do configuration run-time through
custom command. If yes then it can be useful too.

Michal

-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

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

* [U-Boot] [PATCH v2] net: Check network device driver name
  2011-08-30  9:30 [U-Boot] [PATCH v2] net: Check network device driver name Michal Simek
  2011-09-01 14:12 ` Mike Frysinger
@ 2011-09-04 21:29 ` Wolfgang Denk
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2011-09-04 21:29 UTC (permalink / raw)
  To: u-boot

Dear Michal Simek,

In message <1314696613-31095-1-git-send-email-monstr@monstr.eu> you wrote:
> If name is longer than allocated space NAMESIZE
> mac address is rewritten which show error
> message like:
> 
> Error message:
> Warning: Xlltemac.87000000 MAC addresses don't match:
> Address in SROM is         30:00:00:00:00:00
> Address in environment is  00:0a:35:00:6a:04
> 
> NAMESIZE contains Driver name + zero terminated character.
> 
> Signed-off-by: Michal Simek <monstr@monstr.eu>
> 
> ---
> v2: Apply Mike Frysinger version
> ---
>  net/eth.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 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
"There is nothing  so  deadly  as  not  to  hold  up  to  people  the
opportunity to do great and wonderful things, if we wish to stimulate
them in an active way."
- Dr. Harold Urey, Nobel Laureate in chemistry

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

end of thread, other threads:[~2011-09-04 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30  9:30 [U-Boot] [PATCH v2] net: Check network device driver name Michal Simek
2011-09-01 14:12 ` Mike Frysinger
2011-09-02  9:27   ` Michal Simek
2011-09-04 21:29 ` 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.