From e408c42189861b5ca18993e8fbb6975e67d4d442 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Thu, 27 Aug 2015 22:25:54 -0700 Subject: [PATCH] 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 Acked-by: Joe Hershberger --- net/eth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/eth.c b/net/eth.c index c46a8c3050..26520d3038 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); } -- 2.39.5