From: Bin Meng Date: Fri, 28 Aug 2015 05:25:54 +0000 (-0700) Subject: dm: eth: Correctly detect alias in eth_get_dev_by_name() X-Git-Tag: v2015.10-rc4~201 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e408c42189861b5ca18993e8fbb6975e67d4d442;p=u-boot 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 --- 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); }