From 107ed84602bb5b77c333e3a4f373db5e62b50c61 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Fri, 9 Aug 2024 11:54:30 +0200 Subject: [PATCH] ext4: Fix zalloc() Currently, zalloc() calls uncondtionally memset(), if the allocation failes, memset() will write to a null pointer. Fix by using kzalloc(). Signed-off-by: Richard Weinberger Reviewed-by: Heinrich Schuchardt --- fs/ext4/ext4_common.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h index 84500e990a..346752092b 100644 --- a/fs/ext4/ext4_common.h +++ b/fs/ext4/ext4_common.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #if defined(CONFIG_EXT4_WRITE) #include "ext4_journal.h" @@ -43,9 +44,7 @@ static inline void *zalloc(size_t size) { - void *p = memalign(ARCH_DMA_MINALIGN, size); - memset(p, 0, size); - return p; + return kzalloc(size, 0); } int ext4fs_read_inode(struct ext2_data *data, int ino, -- 2.39.5