Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
e142dc1e 102402a7

+5 -10
+1
drivers/uwb/Kconfig
··· 5 5 menuconfig UWB 6 6 tristate "Ultra Wideband devices" 7 7 default n 8 + select GENERIC_NET_UTILS 8 9 help 9 10 UWB is a high-bandwidth, low-power, point-to-point radio 10 11 technology using a wide spectrum (3.1-10.6GHz). It is
+4 -10
drivers/uwb/address.c
··· 336 336 struct uwb_mac_addr addr; 337 337 ssize_t result; 338 338 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; 346 341 if (is_multicast_ether_addr(addr.data)) { 347 342 dev_err(&rc->uwb_dev.dev, "refusing to set multicast " 348 343 "MAC address %s\n", buf); 349 - result = -EINVAL; 350 - goto out; 344 + return -EINVAL; 351 345 } 352 346 result = uwb_rc_mac_addr_set(rc, &addr); 353 347 if (result == 0) 354 348 rc->uwb_dev.mac_addr = addr; 355 - out: 349 + 356 350 return result < 0 ? result : size; 357 351 } 358 352 DEVICE_ATTR(mac_address, S_IRUGO | S_IWUSR, uwb_rc_mac_addr_show, uwb_rc_mac_addr_store);