Message ID | 1314696613-31095-1-git-send-email-monstr@monstr.eu |
---|---|
State | Accepted |
Commit | 58c583b6c2ebc459de018c772fea5437de430063 |
Headers | show |
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
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
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
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();
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(-)