Skip to content

Commit

Permalink
ceph: Use kcalloc for allocating multiple elements
Browse files Browse the repository at this point in the history
Prefer using kcalloc(a, b) over kzalloc(a * b) as this improves
semantics since kcalloc is intended for allocating an array of memory.

Signed-off-by: Kenneth Lee <klee33@uw.edu>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Kenneth Lee authored and Ilya Dryomov committed Oct 4, 2022
1 parent 7c3ea98 commit aa1d627
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
struct ceph_mds_request *req;
int i;

sessions = kzalloc(max_sessions * sizeof(s), GFP_KERNEL);
sessions = kcalloc(max_sessions, sizeof(s), GFP_KERNEL);
if (!sessions) {
err = -ENOMEM;
goto out;
Expand Down

0 comments on commit aa1d627

Please sign in to comment.