projects
/
linux-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
02c7f72
)
ext4: use kmalloc_array() for array space allocation
author
Liao Yuanhong
<liaoyuanhong@vivo.com>
Mon, 11 Aug 2025 12:58:16 +0000
(20:58 +0800)
committer
Theodore Ts'o
<tytso@mit.edu>
Wed, 13 Aug 2025 03:15:05 +0000
(23:15 -0400)
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>
fs/ext4/orphan.c
patch
|
blob
|
blame
|
history
diff --git
a/fs/ext4/orphan.c
b/fs/ext4/orphan.c
index 7c7f792ad6aba9194a08e67801e265bc443486bc..524d4658fa408d4259507c12c333a43d522c467d 100644
(file)
--- a/
fs/ext4/orphan.c
+++ b/
fs/ext4/orphan.c
@@
-589,8
+589,9
@@
int ext4_init_orphan_info(struct super_block *sb)
}
oi->of_blocks = inode->i_size >> sb->s_blocksize_bits;
oi->of_csum_seed = EXT4_I(inode)->i_csum_seed;
- oi->of_binfo = kmalloc(oi->of_blocks*sizeof(struct ext4_orphan_block),
- GFP_KERNEL);
+ oi->of_binfo = kmalloc_array(oi->of_blocks,
+ sizeof(struct ext4_orphan_block),
+ GFP_KERNEL);
if (!oi->of_binfo) {
ret = -ENOMEM;
goto out_put;