From: Dan Carpenter Date: Mon, 17 Jul 2017 08:13:35 +0000 (+0300) Subject: libceph: potential NULL dereference in ceph_msg_data_create() X-Git-Tag: v5.15~10812^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c40b22f6f84c98a1d36e6d0a4346e58f05e45d8;p=platform%2Fkernel%2Flinux-starfive.git 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 Signed-off-by: Ilya Dryomov --- diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 0c31035..b7cc615 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;