]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ceph: fix dereference of null pointer cf
authorColin Ian King <colin.king@canonical.com>
Sun, 29 Aug 2021 18:18:24 +0000 (19:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:41:44 +0000 (13:41 +0200)
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>
fs/ceph/caps.c

index 805c656a2e72ad378ac5915e6f345f846ee40827..f602e51c00065474e7866c654275ea81be7e234c 100644 (file)
@@ -1756,6 +1756,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;
 }