[PATCH] usb: gadget: u_ether: replace memcpy() with ether_addr_copy() for MAC

Nikolay Kulikov <[email protected]>
Newsgroups org.kernel.vger.linux-usb,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
There is a function for copying a MAC address buffer in
include/linux/etherdevice.h, so use it instead of memcpy().

Signed-off-by: Nikolay Kulikov <[email protected]>
---
 drivers/usb/gadget/function/u_ether.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 59d85d6a84a8..62f95de03f32 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -779,7 +779,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 			"using random %s ethernet address\n", "host");
 
 	if (ethaddr)
-		memcpy(ethaddr, dev->host_mac, ETH_ALEN);
+		ether_addr_copy(ethaddr, dev->host_mac);
 
 	net->netdev_ops = &eth_netdev_ops;
 
@@ -929,7 +929,7 @@ int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
 	dev = netdev_priv(net);
 	if (get_ether_addr(dev_addr, new_addr))
 		return -EINVAL;
-	memcpy(dev->dev_mac, new_addr, ETH_ALEN);
+	ether_addr_copy(dev->dev_mac, new_addr);
 	net->addr_assign_type = NET_ADDR_SET;
 	return 0;
 }
@@ -959,7 +959,7 @@ int gether_set_host_addr(struct net_device *net, const char *host_addr)
 	dev = netdev_priv(net);
 	if (get_ether_addr(host_addr, new_addr))
 		return -EINVAL;
-	memcpy(dev->host_mac, new_addr, ETH_ALEN);
+	ether_addr_copy(dev->host_mac, new_addr);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(gether_set_host_addr);
@@ -1001,7 +1001,7 @@ void gether_get_host_addr_u8(struct net_device *net, u8 host_mac[ETH_ALEN])
 	struct eth_dev *dev;
 
 	dev = netdev_priv(net);
-	memcpy(host_mac, dev->host_mac, ETH_ALEN);
+	ether_addr_copy(host_mac, dev->host_mac);
 }
 EXPORT_SYMBOL_GPL(gether_get_host_addr_u8);
 

---
base-commit: e6664f2b33db9b6811eb4cec109f06cb2b4f458d
change-id: 20260818-gether_copy_ether_addr-e1fad0b218b0

Best regards,
--  
Nikolay Kulikov <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.