]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: erofs: xattr.c change kzalloc to kcalloc
authorEthan Carter Edwards <ethan@ethancedwards.com>
Mon, 23 Dec 2024 02:23:56 +0000 (21:23 -0500)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 16 Jan 2025 19:17:20 +0000 (03:17 +0800)
Refactor xattr.c to use kcalloc instead of kzalloc when multiplying
allocation size by count. This refactor prevents unintentional
memory overflows. Discovered by checkpatch.pl.

Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
Link: https://lore.kernel.org/r/i3CLJhMELKzBJr3DaRyv-hP_4m-3Twx0sgBWXW6naZlMtHrIeWr93xOFshX8qZHDrJeSjHMTiUOh8JmBZ9v0AB-S1lIYM_d-vasSRlsF_s4=@ethancedwards.com
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/xattr.c

index a90d7d649739051db77fb543cd69090512535346..7940241d9355de4f2c0129318701b16b22d54ae3 100644 (file)
@@ -478,7 +478,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
        if (!sbi->xattr_prefix_count)
                return 0;
 
-       pfs = kzalloc(sbi->xattr_prefix_count * sizeof(*pfs), GFP_KERNEL);
+       pfs = kcalloc(sbi->xattr_prefix_count, sizeof(*pfs), GFP_KERNEL);
        if (!pfs)
                return -ENOMEM;