MAC address is often written without leading zeros. Example: 00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe Convention of skipping leading zeros is used in libc. enther_ntoa_r() generates MAC address without leading zeros. Fix get_ether_addr() to correctly parse MAC address with and without leading zeros. Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> --- drivers/usb/gadget/function/u_ether.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index f1fd777..1e3ee2a 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -713,9 +713,11 @@ static int get_ether_addr(const char *str, u8 *dev_addr) if ((*str == '.') || (*str == ':')) str++; - num = hex_to_bin(*str++) << 4; - num |= hex_to_bin(*str++); - dev_addr [i] = num; + + num = hex_to_bin(*str++); + if ((*str != '.') && (*str != ':')) + num = num << 4 | hex_to_bin(*str++); + dev_addr[i] = num; } if (is_valid_ether_addr(dev_addr)) return 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html