Skip to content

Commit

Permalink
ceph: fix dereference of null pointer cf
Browse files Browse the repository at this point in the history
commit 05a444d 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: b2f9fa1 ("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>
  • Loading branch information
Colin Ian King authored and gregkh committed Sep 18, 2021
1 parent b867838 commit bf3f35d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/ceph/caps.c
Expand Up @@ -1746,6 +1746,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;
}
Expand Down

0 comments on commit bf3f35d

Please sign in to comment.