https://github.com/torvalds/linux
Revision 5fa77b54eff1e4fb38494b5a24c66768d6e7c148 authored by Linus Torvalds on 13 July 2014, 19:09:18 UTC, committed by Linus Torvalds on 13 July 2014, 19:09:18 UTC
Pull ARM fixes from Russell King:
 "Another round of fixes for ARM:
   - a set of kprobes fixes from Jon Medhurst
   - fix the revision checking for the L2 cache which wasn't noticed to
     have been broken"

* 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm:
  ARM: l2c: fix revision checking
  ARM: kprobes: Fix test code compilation errors for ARMv4 targets
  ARM: kprobes: Disallow instructions with PC and register specified shift
  ARM: kprobes: Prevent known test failures stopping other tests running
2 parent s 33fe3ae + cda390b
Raw File
Tip revision: 5fa77b54eff1e4fb38494b5a24c66768d6e7c148 authored by Linus Torvalds on 13 July 2014, 19:09:18 UTC
Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm
Tip revision: 5fa77b5
net_utils.c
#include <linux/string.h>
#include <linux/if_ether.h>
#include <linux/ctype.h>
#include <linux/kernel.h>

int mac_pton(const char *s, u8 *mac)
{
	int i;

	/* XX:XX:XX:XX:XX:XX */
	if (strlen(s) < 3 * ETH_ALEN - 1)
		return 0;

	/* Don't dirty result unless string is valid MAC. */
	for (i = 0; i < ETH_ALEN; i++) {
		if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
			return 0;
		if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
			return 0;
	}
	for (i = 0; i < ETH_ALEN; i++) {
		mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
	}
	return 1;
}
EXPORT_SYMBOL(mac_pton);
back to top