summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2012-08-02 09:12:59 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-26 11:38:42 -0800
commitb8e03e320f9156e870f8cc66b0d9fca9f24d36c8 (patch)
tree230886a24e185f2f8e2120f05456c823d47c62f9 /net
parent59238927cc8ea6c1e4a8a1136e17598648832db0 (diff)
downloadlinux-3.10-b8e03e320f9156e870f8cc66b0d9fca9f24d36c8.tar.gz
linux-3.10-b8e03e320f9156e870f8cc66b0d9fca9f24d36c8.tar.bz2
linux-3.10-b8e03e320f9156e870f8cc66b0d9fca9f24d36c8.zip
libceph: fix crypto key null deref, memory leak
(cherry picked from commit f0666b1ac875ff32fe290219b150ec62eebbe10e) 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/crypto.c1
-rw-r--r--net/ceph/crypto.h3
2 files changed, 3 insertions, 1 deletions
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index b780cb7947d..9da7fdd3cd8 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -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 = {
diff --git a/net/ceph/crypto.h b/net/ceph/crypto.h
index 1919d1550d7..3572dc518bc 100644
--- a/net/ceph/crypto.h
+++ b/net/ceph/crypto.h
@@ -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,