diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-07-17 10:13:35 +0200 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-07-17 14:54:59 +0200 |
commit | 7c40b22f6f84c98a1d36e6d0a4346e58f05e45d8 (patch) | |
tree | 83ca96fd7f28d2efc8ba8fa8dcabc37a3ba82ba1 /net/ceph/messenger.c | |
parent | ceph: fix race in concurrent readdir (diff) | |
download | linux-7c40b22f6f84c98a1d36e6d0a4346e58f05e45d8.tar.xz linux-7c40b22f6f84c98a1d36e6d0a4346e58f05e45d8.zip |
libceph: potential NULL dereference in ceph_msg_data_create()
If kmem_cache_zalloc() returns NULL then the INIT_LIST_HEAD(&data->links);
will Oops. The callers aren't really prepared for NULL returns so it
doesn't make a lot of difference in real life.
Fixes: 5240d9f95dfe ("libceph: replace message data pointer with list")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r-- | net/ceph/messenger.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 0c31035bbfee..b7cc615d42ef 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -3203,8 +3203,10 @@ static struct ceph_msg_data *ceph_msg_data_create(enum ceph_msg_data_type type) return NULL; data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS); - if (data) - data->type = type; + if (!data) + return NULL; + + data->type = type; INIT_LIST_HEAD(&data->links); return data; |