aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2017-07-17 04:13:35 -0400
committerIlya Dryomov <idryomov@gmail.com>2017-07-17 08:54:59 -0400
commit7c40b22f6f84c98a1d36e6d0a4346e58f05e45d8 (patch)
tree83ca96fd7f28d2efc8ba8fa8dcabc37a3ba82ba1
parent84583cfb973c4313955c6231cc9cb3772d280b15 (diff)
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>
-rw-r--r--net/ceph/messenger.c6
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)
3203 return NULL; 3203 return NULL;
3204 3204
3205 data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS); 3205 data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS);
3206 if (data) 3206 if (!data)
3207 data->type = type; 3207 return NULL;
3208
3209 data->type = type;
3208 INIT_LIST_HEAD(&data->links); 3210 INIT_LIST_HEAD(&data->links);
3209 3211
3210 return data; 3212 return data;