[PATCH 1/2] e2fsck: fix to return ENOMEM in alloc_size_dir()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wang Shilong <wshilong@xxxxxxx>

Two memory allocation return check is missed.

Signed-off-by: Wang Shilong <wshilong@xxxxxxx>
---
 e2fsck/rehash.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index a5fc1be1..5250652e 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -272,7 +272,11 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
 		outdir->hashes = new_mem;
 	} else {
 		outdir->buf = malloc(blocks * fs->blocksize);
+		if (!outdir->buf)
+			return ENOMEM;
 		outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t));
+		if (!outdir->hashes)
+			return ENOMEM;
 		outdir->num = 0;
 	}
 	outdir->max = blocks;
-- 
2.21.0




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux