Skip to content

Commit

Permalink
security/keys: use kvfree_sensitive()
Browse files Browse the repository at this point in the history
Use kvfree_sensitive() instead of open-coding it.

Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Ben Boeckel <mathstuf@gmail.com>
  • Loading branch information
evdenis authored and dhowells committed Jan 21, 2021
1 parent 8fe62e0 commit 272a121
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions security/keys/big_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
*path = file->f_path;
path_get(path);
fput(file);
memzero_explicit(buf, enclen);
kvfree(buf);
kvfree_sensitive(buf, enclen);
} else {
/* Just store the data in a buffer */
void *data = kmalloc(datalen, GFP_KERNEL);
Expand All @@ -140,8 +139,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
err_enckey:
kfree_sensitive(enckey);
error:
memzero_explicit(buf, enclen);
kvfree(buf);
kvfree_sensitive(buf, enclen);
return ret;
}

Expand Down Expand Up @@ -273,8 +271,7 @@ long big_key_read(const struct key *key, char *buffer, size_t buflen)
err_fput:
fput(file);
error:
memzero_explicit(buf, enclen);
kvfree(buf);
kvfree_sensitive(buf, enclen);
} else {
ret = datalen;
memcpy(buffer, key->payload.data[big_key_data], datalen);
Expand Down

0 comments on commit 272a121

Please sign in to comment.