Skip to content

Commit 5e14e70

Browse files
Liao Yuanhonggregkh
authored andcommitted
ext4: use kmalloc_array() for array space allocation
commit 76dba1f upstream. Replace kmalloc(size * sizeof) with kmalloc_array() for safer memory allocation and overflow prevention. Cc: stable@kernel.org Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com> Link: https://patch.msgid.link/20250811125816.570142-1-liaoyuanhong@vivo.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2ea0fcc commit 5e14e70

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/ext4/orphan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,9 @@ int ext4_init_orphan_info(struct super_block *sb)
589589
}
590590
oi->of_blocks = inode->i_size >> sb->s_blocksize_bits;
591591
oi->of_csum_seed = EXT4_I(inode)->i_csum_seed;
592-
oi->of_binfo = kmalloc(oi->of_blocks*sizeof(struct ext4_orphan_block),
593-
GFP_KERNEL);
592+
oi->of_binfo = kmalloc_array(oi->of_blocks,
593+
sizeof(struct ext4_orphan_block),
594+
GFP_KERNEL);
594595
if (!oi->of_binfo) {
595596
ret = -ENOMEM;
596597
goto out_put;

0 commit comments

Comments
 (0)