]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
libceph: potential NULL dereference in ceph_msg_data_create()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 17 Jul 2017 08:13:35 +0000 (11:13 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 17 Jul 2017 12:54:59 +0000 (14:54 +0200)
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>
net/ceph/messenger.c

index 0c31035bbfee8cd682ccf63b3e00728b6252f545..b7cc615d42efdb2219771c7a83c0acd5fa9ea9f5 100644 (file)
@@ -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;