summaryrefslogtreecommitdiff
path: root/fs/ceph
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-08-29 21:18:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-18 14:40:06 +0300
commit8248b61b86fb5ff2980de57ead707bbd28c78ea3 (patch)
tree498ae52151470c9de1326882625460ac052300a1 /fs/ceph
parentc37085d606349bd312903d1957d174ca52503cf8 (diff)
downloadlinux-8248b61b86fb5ff2980de57ead707bbd28c78ea3.tar.xz
ceph: fix dereference of null pointer cf
commit 05a444d3f90a3c3e6362e88a1bf13e1a60f8cace upstream. Currently in the case where kmem_cache_alloc fails the null pointer cf is dereferenced when assigning cf->is_capsnap = false. Fix this by adding a null pointer check and return path. Cc: stable@vger.kernel.org Addresses-Coverity: ("Dereference null return") Fixes: b2f9fa1f3bd8 ("ceph: correctly handle releasing an embedded cap flush") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/caps.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index b864c9b9e8df..678dac8365ed 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1755,6 +1755,9 @@ struct ceph_cap_flush *ceph_alloc_cap_flush(void)
struct ceph_cap_flush *cf;
cf = kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL);
+ if (!cf)
+ return NULL;
+
cf->is_capsnap = false;
return cf;
}