summaryrefslogtreecommitdiff
path: root/net/eth.c
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2015-08-27 22:25:54 -0700
committerSimon Glass <sjg@chromium.org>2015-09-09 07:48:03 -0600
commite408c42189861b5ca18993e8fbb6975e67d4d442 (patch)
tree9f6f55b095b1b7a64ae92fe2964c2dc47be3af72 /net/eth.c
parent71d7971facdba763c220ca2cfdbd181e907eae89 (diff)
downloadu-boot-imx-e408c42189861b5ca18993e8fbb6975e67d4d442.zip
u-boot-imx-e408c42189861b5ca18993e8fbb6975e67d4d442.tar.gz
u-boot-imx-e408c42189861b5ca18993e8fbb6975e67d4d442.tar.bz2
dm: eth: Correctly detect alias in eth_get_dev_by_name()
When given a device name string, we should test to see if it is really an alias like "eth#". Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'net/eth.c')
-rw-r--r--net/eth.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/eth.c b/net/eth.c
index c46a8c3..26520d3 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -195,10 +195,11 @@ struct udevice *eth_get_dev_by_name(const char *devname)
const char *startp = NULL;
struct udevice *it;
struct uclass *uc;
+ int len = strlen("eth");
/* Must be longer than 3 to be an alias */
- if (strlen(devname) > strlen("eth")) {
- startp = devname + strlen("eth");
+ if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
+ startp = devname + len;
seq = simple_strtoul(startp, &endp, 10);
}