aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2017-04-27 11:49:33 -0400
committerMike Snitzer <snitzer@redhat.com>2017-04-27 12:10:16 -0400
commit6625d903253eb6f003849823e22d7b8de5bfb5b2 (patch)
tree32814302241023500154ce45da6472defd8c23d9
parente944e03e336f7ffa02aabc71291933d93dcd077c (diff)
dm integrity: use hex2bin instead of open-coded variant
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-integrity.c14
1 files changed, 2 insertions, 12 deletions
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
2496 2496
2497 k = strchr(a->alg_string, ':'); 2497 k = strchr(a->alg_string, ':');
2498 if (k) { 2498 if (k) {
2499 unsigned i;
2500
2501 *k = 0; 2499 *k = 0;
2502 a->key_string = k + 1; 2500 a->key_string = k + 1;
2503 if (strlen(a->key_string) & 1) 2501 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
2507 a->key = kmalloc(a->key_size, GFP_KERNEL); 2505 a->key = kmalloc(a->key_size, GFP_KERNEL);
2508 if (!a->key) 2506 if (!a->key)
2509 goto nomem; 2507 goto nomem;
2510 for (i = 0; i < a->key_size; i++) { 2508 if (hex2bin(a->key, a->key_string, a->key_size))
2511 char digit[3]; 2509 goto inval;
2512 digit[0] = a->key_string[i * 2];
2513 digit[1] = a->key_string[i * 2 + 1];
2514 digit[2] = 0;
2515 if (strspn(digit, "0123456789abcdefABCDEF") != 2)
2516 goto inval;
2517 if (kstrtou8(digit, 16, &a->key[i]))
2518 goto inval;
2519 }
2520 } 2510 }
2521 2511
2522 return 0; 2512 return 0;