summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonrad Gräfe <k.graefe@gateware.de>2023-05-05 16:36:40 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-24 17:36:52 +0100
commit0ed9257a8ab9be1263f5cc7ab55f3e5688e6e685 (patch)
tree4753a98a26141610db369b23566465e34251a144
parentc51a131cacf41793c661e3c32f6fe3bd3dc0f67d (diff)
downloadlinux-0ed9257a8ab9be1263f5cc7ab55f3e5688e6e685.tar.gz
linux-0ed9257a8ab9be1263f5cc7ab55f3e5688e6e685.tar.bz2
linux-0ed9257a8ab9be1263f5cc7ab55f3e5688e6e685.zip
usb: gadget: u_ether: Fix host MAC address case
commit 3c0f4f09c063e143822393d99cb2b19a85451c07 upstream. The CDC-ECM specification [1] requires to send the host MAC address as an uppercase hexadecimal string in chapter "5.4 Ethernet Networking Functional Descriptor": The Unicode character is chosen from the set of values 30h through 39h and 41h through 46h (0-9 and A-F). However, snprintf(.., "%pm", ..) generates a lowercase MAC address string. While most host drivers are tolerant to this, UsbNcm.sys on Windows 10 is not. Instead it uses a different MAC address with all bytes set to zero including and after the first byte containing a lowercase letter. On Windows 11 Microsoft fixed it, but apparently they did not backport the fix. This change fixes the issue by upper-casing the MAC to comply with the specification. [1]: https://www.usb.org/document-library/class-definitions-communication-devices-12, file ECM120.pdf Fixes: bcd4a1c40bee ("usb: gadget: u_ether: construct with default values and add setters/getters") Cc: stable@vger.kernel.org Signed-off-by: Konrad Gräfe <k.graefe@gateware.de> Link: https://lore.kernel.org/r/20230505143640.443014-1-k.graefe@gateware.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/gadget/function/u_ether.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index ef253599dcf9..116dbc2ae04d 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -18,6 +18,7 @@
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/etherdevice.h>
+#include <linux/string_helpers.h>
#include "u_ether.h"
@@ -976,6 +977,8 @@ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len)
dev = netdev_priv(net);
snprintf(host_addr, len, "%pm", dev->host_mac);
+ string_upper(host_addr, host_addr);
+
return strlen(host_addr);
}
EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc);