Skip to content

Commit 05a444d

Browse files
Colin Ian Kingidryomov
authored andcommitted
ceph: fix dereference of null pointer cf
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: [email protected] Addresses-Coverity: ("Dereference null return") Fixes: b2f9fa1 ("ceph: correctly handle releasing an embedded cap flush") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 9f35899 commit 05a444d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/ceph/caps.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,9 @@ struct ceph_cap_flush *ceph_alloc_cap_flush(void)
17361736
struct ceph_cap_flush *cf;
17371737

17381738
cf = kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL);
1739+
if (!cf)
1740+
return NULL;
1741+
17391742
cf->is_capsnap = false;
17401743
return cf;
17411744
}

0 commit comments

Comments
 (0)