Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: u_ether: replace memcpy() with ether_addr_copy() for MAC
@ 2026-08-19 20:56 Nikolay Kulikov
  0 siblings, 0 replies; only message in thread
From: Nikolay Kulikov @ 2026-08-19 20:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Nikolay Kulikov

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 <nikolayof23@gmail.com>
---
 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 <nikolayof23@gmail.com>


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-19 20:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 20:56 [PATCH] usb: gadget: u_ether: replace memcpy() with ether_addr_copy() for MAC Nikolay Kulikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox