Skip to content

Commit

Permalink
libceph: fix crypto key null deref, memory leak
Browse files Browse the repository at this point in the history
Avoid crashing if the crypto key payload was NULL, as when it was not correctly
allocated and initialized.  Also, avoid leaking it.

Signed-off-by: Sylvain Munaut <[email protected]>
Signed-off-by: Sage Weil <[email protected]>
Reviewed-by: Alex Elder <[email protected]>
  • Loading branch information
smunaut authored and Sage Weil committed Aug 2, 2012
1 parent 5ef50c3 commit f0666b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions net/ceph/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ void ceph_key_destroy(struct key *key) {
struct ceph_crypto_key *ckey = key->payload.data;

ceph_crypto_key_destroy(ckey);
kfree(ckey);
}

struct key_type key_type_ceph = {
Expand Down
3 changes: 2 additions & 1 deletion net/ceph/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct ceph_crypto_key {

static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key)
{
kfree(key->key);
if (key)
kfree(key->key);
}

extern int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
Expand Down

0 comments on commit f0666b1

Please sign in to comment.