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 <richard@nod.at>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
Richard Weinberger 2024-08-09 11:54:30 +02:00 committed by Tom Rini
parent a29805d822
commit 107ed84602

View 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,