Whamcloud - gitweb
e2fsck: fix to return ENOMEM in alloc_size_dir()
authorWang Shilong <wshilong@ddn.com>
Tue, 26 Nov 2019 09:03:58 +0000 (18:03 +0900)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 1 Jan 2020 18:41:34 +0000 (13:41 -0500)
Two memory allocation return check is missed.

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/rehash.c

index 2c908be..392cfe9 100644 (file)
@@ -276,7 +276,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;