[PATCH] init: Use kcalloc() instead of kzalloc()

From: Mehdi Ben Hadj Khelifa

Date: Tue Sep 30 2025 - 04:35:35 EST


Replace kzalloc() with kcalloc() in init/initramfs_test.c since the
calculation inside kzalloc is dynamic and could overflow.

Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@xxxxxxxxx>
---
init/initramfs_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/initramfs_test.c b/init/initramfs_test.c
index 517e5e04e5cc..fed1911b73cb 100644
--- a/init/initramfs_test.c
+++ b/init/initramfs_test.c
@@ -97,7 +97,7 @@ static void __init initramfs_test_extract(struct kunit *test)
} };

/* +3 to cater for any 4-byte end-alignment */
- cpio_srcbuf = kzalloc(ARRAY_SIZE(c) * (CPIO_HDRLEN + PATH_MAX + 3),
+ cpio_srcbuf = kcalloc(ARRAY_SIZE(c), (CPIO_HDRLEN + PATH_MAX + 3),
GFP_KERNEL);
len = fill_cpio(c, ARRAY_SIZE(c), cpio_srcbuf);

--
2.51.0