Commit 1f2f72ef authored by Kenneth Lee's avatar Kenneth Lee Committed by sanglipeng
Browse files

ceph: Use kcalloc for allocating multiple elements

stable inclusion
from stable-v5.10.157
commit 00c004c070f22a47063de4ff2a5638fce1f94d95
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MU59

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=00c004c070f22a47063de4ff2a5638fce1f94d95



--------------------------------

[ Upstream commit aa1d6272 ]

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: default avatarKenneth Lee <klee33@uw.edu>
Reviewed-by: default avatarXiubo Li <xiubli@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Stable-dep-of: 5bd76b8d ("ceph: fix NULL pointer dereference for req->r_session")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 60dfdf31
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2335,7 +2335,7 @@ static int unsafe_request_wait(struct inode *inode)
		struct ceph_mds_request *req;
		struct ceph_mds_request *req;
		int i;
		int i;


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