]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ubifs: Fix memory leak in read_znode() error path
authorWenwen Wang <wenwen@cs.uga.edu>
Tue, 20 Aug 2019 03:03:46 +0000 (22:03 -0500)
committerRichard Weinberger <richard@nod.at>
Sun, 15 Sep 2019 20:11:18 +0000 (22:11 +0200)
In read_znode(), the indexing node 'idx' is allocated by kmalloc().
However, it is not deallocated in the following execution if
ubifs_node_check_hash() fails, leading to a memory leak bug. To fix this
issue, free 'idx' before returning the error.

Fixes: 16a26b20d2af ("ubifs: authentication: Add hashes to index nodes")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/tnc_misc.c

index 6f293f662d983afed23d90649134c6b915c4d69a..49cb34c3f3243213446cf75d1d0e4d4c6c7e25e7 100644 (file)
@@ -284,6 +284,7 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
        err = ubifs_node_check_hash(c, idx, zzbr->hash);
        if (err) {
                ubifs_bad_hash(c, idx, zzbr->hash, lnum, offs);
+               kfree(idx);
                return err;
        }