All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <monstr@monstr.eu>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] net: Check network device driver name
Date: Tue, 30 Aug 2011 11:30:13 +0200	[thread overview]
Message-ID: <1314696613-31095-1-git-send-email-monstr@monstr.eu> (raw)

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

             reply	other threads:[~2011-08-30  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30  9:30 Michal Simek [this message]
2011-09-01 14:12 ` [U-Boot] [PATCH v2] net: Check network device driver name Mike Frysinger
2011-09-02  9:27   ` Michal Simek
2011-09-04 21:29 ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314696613-31095-1-git-send-email-monstr@monstr.eu \
    --to=monstr@monstr.eu \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.