[PATCH 2/2] um: vector: Use mac_pton() for MAC address parsing
Tiwei Bie
tiwei.btw at antgroup.com
Mon May 5 21:51:17 PDT 2025
Use mac_pton() instead of custom approach.
Suggested-by: Geert Uytterhoeven <geert at linux-m68k.org>
Signed-off-by: Tiwei Bie <tiwei.btw at antgroup.com>
---
arch/um/drivers/vector_kern.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 7822421057ea..5226d2c52e6a 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1543,21 +1543,14 @@ static void vector_timer_expire(struct timer_list *t)
static void vector_setup_etheraddr(struct net_device *dev, char *str)
{
u8 addr[ETH_ALEN];
- char *end;
- int i;
if (str == NULL)
goto random;
- for (i = 0; i < 6; i++) {
- addr[i] = simple_strtoul(str, &end, 16);
- if ((end == str) ||
- ((*end != ':') && (*end != ',') && (*end != '\0'))) {
- netdev_err(dev,
- "Failed to parse '%s' as an ethernet address\n", str);
- goto random;
- }
- str = end + 1;
+ if (!mac_pton(str, addr)) {
+ netdev_err(dev,
+ "Failed to parse '%s' as an ethernet address\n", str);
+ goto random;
}
if (is_multicast_ether_addr(addr)) {
netdev_err(dev,
--
2.34.1
More information about the linux-um
mailing list