From 6625d903253eb6f003849823e22d7b8de5bfb5b2 Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Thu, 27 Apr 2017 11:49:33 -0400 Subject: dm integrity: use hex2bin instead of open-coded variant Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer --- drivers/md/dm-integrity.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/md/dm-integrity.c') diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 0354af4cd713..023d3f8a51cc 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -2496,8 +2496,6 @@ static int get_alg_and_key(const char *arg, struct alg_spec *a, char **error, ch k = strchr(a->alg_string, ':'); if (k) { - unsigned i; - *k = 0; a->key_string = k + 1; if (strlen(a->key_string) & 1) @@ -2507,16 +2505,8 @@ static int get_alg_and_key(const char *arg, struct alg_spec *a, char **error, ch a->key = kmalloc(a->key_size, GFP_KERNEL); if (!a->key) goto nomem; - for (i = 0; i < a->key_size; i++) { - char digit[3]; - digit[0] = a->key_string[i * 2]; - digit[1] = a->key_string[i * 2 + 1]; - digit[2] = 0; - if (strspn(digit, "0123456789abcdefABCDEF") != 2) - goto inval; - if (kstrtou8(digit, 16, &a->key[i])) - goto inval; - } + if (hex2bin(a->key, a->key_string, a->key_size)) + goto inval; } return 0; -- cgit v1.2.3