diff options
| author | Sylvain Munaut <tnt@246tNt.com> | 2012-08-02 12:12:59 -0400 |
|---|---|---|
| committer | Sage Weil <sage@inktank.com> | 2012-08-02 12:19:20 -0400 |
| commit | f0666b1ac875ff32fe290219b150ec62eebbe10e (patch) | |
| tree | 9f38d4c5ac83b77812692ccd2db6a880bf63cf9d /net/ceph | |
| parent | 5ef50c3bec20060bc114f62d6503c5d86d70bdd7 (diff) | |
libceph: fix crypto key null deref, memory leak
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 <tnt@246tNt.com>
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'net/ceph')
| -rw-r--r-- | net/ceph/crypto.c | 1 | ||||
| -rw-r--r-- | net/ceph/crypto.h | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c index b780cb7947dd..9da7fdd3cd8a 100644 --- a/net/ceph/crypto.c +++ b/net/ceph/crypto.c | |||
| @@ -466,6 +466,7 @@ void ceph_key_destroy(struct key *key) { | |||
| 466 | struct ceph_crypto_key *ckey = key->payload.data; | 466 | struct ceph_crypto_key *ckey = key->payload.data; |
| 467 | 467 | ||
| 468 | ceph_crypto_key_destroy(ckey); | 468 | ceph_crypto_key_destroy(ckey); |
| 469 | kfree(ckey); | ||
| 469 | } | 470 | } |
| 470 | 471 | ||
| 471 | struct key_type key_type_ceph = { | 472 | struct key_type key_type_ceph = { |
diff --git a/net/ceph/crypto.h b/net/ceph/crypto.h index 1919d1550d75..3572dc518bc9 100644 --- a/net/ceph/crypto.h +++ b/net/ceph/crypto.h | |||
| @@ -16,7 +16,8 @@ struct ceph_crypto_key { | |||
| 16 | 16 | ||
| 17 | static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key) | 17 | static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key) |
| 18 | { | 18 | { |
| 19 | kfree(key->key); | 19 | if (key) |
| 20 | kfree(key->key); | ||
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | extern int ceph_crypto_key_clone(struct ceph_crypto_key *dst, | 23 | extern int ceph_crypto_key_clone(struct ceph_crypto_key *dst, |
