Skip to content

Commit

Permalink
dm integrity: use hex2bin instead of open-coded variant
Browse files Browse the repository at this point in the history
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Mikulas Patocka authored and Mike Snitzer committed Apr 27, 2017
1 parent e944e03 commit 6625d90
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions drivers/md/dm-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 6625d90

Please sign in to comment.