]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ext4: Fix zalloc()
authorRichard Weinberger <richard@nod.at>
Fri, 9 Aug 2024 09:54:30 +0000 (11:54 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 15 Aug 2024 22:14:36 +0000 (16:14 -0600)
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 <richard@nod.at>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
fs/ext4/ext4_common.h

index 84500e990aa36e4babc8619b22e01722e0b27aad..346752092b05e3a03d0726ce53bc4502485bb3e9 100644 (file)
@@ -24,6 +24,7 @@
 #include <ext4fs.h>
 #include <malloc.h>
 #include <asm/cache.h>
+#include <linux/compat.h>
 #include <linux/errno.h>
 #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,