ceph: Use kcalloc for allocating multiple elements
authorKenneth Lee <klee33@uw.edu>
Fri, 19 Aug 2022 05:42:55 +0000 (22:42 -0700)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 4 Oct 2022 17:18:08 +0000 (19:18 +0200)
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>
fs/ceph/caps.c

index 0dc1251..fb023f9 100644 (file)
@@ -2286,7 +2286,7 @@ retry:
                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;