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: KARO-TXSD-2017-03-15~3419 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e408c42189861b5ca18993e8fbb6975e67d4d442;hp=71d7971facdba763c220ca2cfdbd181e907eae89;p=karo-tx-uboot.git 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); }