linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] e2fsck: fix to return ENOMEM in alloc_size_dir()
@ 2019-11-26  9:03 Wang Shilong
  2019-11-26  9:03 ` [PATCH 2/2] e2fsck: fix use after free in calculate_tree() Wang Shilong
  2019-12-31  3:11 ` [PATCH 1/2] e2fsck: fix to return ENOMEM in alloc_size_dir() Theodore Y. Ts'o
  0 siblings, 2 replies; 7+ messages in thread
From: Wang Shilong @ 2019-11-26  9:03 UTC (permalink / raw)
  To: linux-ext4; +Cc: adilger, lixi, wshilong

From: Wang Shilong <wshilong@ddn.com>

Two memory allocation return check is missed.

Signed-off-by: Wang Shilong <wshilong@ddn.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-12-31  3:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26  9:03 [PATCH 1/2] e2fsck: fix to return ENOMEM in alloc_size_dir() Wang Shilong
2019-11-26  9:03 ` [PATCH 2/2] e2fsck: fix use after free in calculate_tree() Wang Shilong
2019-12-30 11:38   ` Wang Shilong
2019-12-30 17:06   ` Theodore Y. Ts'o
2019-12-31  0:57   ` Theodore Y. Ts'o
2019-12-31  1:41     ` Wang Shilong
2019-12-31  3:11 ` [PATCH 1/2] e2fsck: fix to return ENOMEM in alloc_size_dir() Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).