diff options
author | Wenwen Wang <wenwen@cs.uga.edu> | 2019-08-19 22:03:46 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2019-09-15 22:11:18 +0200 |
commit | ce4d8b16e64d062f1c6271a0068dbbbba2dee620 (patch) | |
tree | 4ac39ccaa98c63ebfdd0fc85ec415ba0fa84f510 /fs/ubifs | |
parent | 8615b94f029a4fb4306d3512aaf1c45f5fc24d4b (diff) | |
download | linux-riscv-ce4d8b16e64d062f1c6271a0068dbbbba2dee620.tar.gz linux-riscv-ce4d8b16e64d062f1c6271a0068dbbbba2dee620.tar.bz2 linux-riscv-ce4d8b16e64d062f1c6271a0068dbbbba2dee620.zip |
ubifs: Fix memory leak in read_znode() error path
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>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/tnc_misc.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c index 6f293f662d98..49cb34c3f324 100644 --- a/fs/ubifs/tnc_misc.c +++ b/fs/ubifs/tnc_misc.c @@ -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; } |