Skip to content

Commit e142dc1

Browse files
andy-shevgregkh
authored andcommitted
uwb: Replace mac address parsing
Replace sscanf() with mac_pton(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 102402a commit e142dc1

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

‎drivers/uwb/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
menuconfig UWB
66
tristate "Ultra Wideband devices"
77
default n
8+
select GENERIC_NET_UTILS
89
help
910
UWB is a high-bandwidth, low-power, point-to-point radio
1011
technology using a wide spectrum (3.1-10.6GHz). It is

‎drivers/uwb/address.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,17 @@ static ssize_t uwb_rc_mac_addr_store(struct device *dev,
336336
struct uwb_mac_addr addr;
337337
ssize_t result;
338338

339-
result = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
340-
&addr.data[0], &addr.data[1], &addr.data[2],
341-
&addr.data[3], &addr.data[4], &addr.data[5]);
342-
if (result != 6) {
343-
result = -EINVAL;
344-
goto out;
345-
}
339+
if (!mac_pton(buf, addr.data))
340+
return -EINVAL;
346341
if (is_multicast_ether_addr(addr.data)) {
347342
dev_err(&rc->uwb_dev.dev, "refusing to set multicast "
348343
"MAC address %s\n", buf);
349-
result = -EINVAL;
350-
goto out;
344+
return -EINVAL;
351345
}
352346
result = uwb_rc_mac_addr_set(rc, &addr);
353347
if (result == 0)
354348
rc->uwb_dev.mac_addr = addr;
355-
out:
349+
356350
return result < 0 ? result : size;
357351
}
358352
DEVICE_ATTR(mac_address, S_IRUGO | S_IWUSR, uwb_rc_mac_addr_show, uwb_rc_mac_addr_store);

0 commit comments

Comments
 (0)