]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dm integrity: use hex2bin instead of open-coded variant
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 27 Apr 2017 15:49:33 +0000 (11:49 -0400)
committerMike Snitzer <snitzer@redhat.com>
Thu, 27 Apr 2017 16:10:16 +0000 (12:10 -0400)
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-integrity.c

index 0354af4cd7139d1d7c07bdd2966c83838b2609b1..023d3f8a51ccb2d71aca5dd240d2f02f3817657c 100644 (file)
@@ -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;