Skip to content

Commit

Permalink
ubifs: Fix memory leak in read_znode() error path
Browse files Browse the repository at this point in the history
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: 16a26b2 ("ubifs: authentication: Add hashes to index nodes")
Signed-off-by: Wenwen Wang <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
wenwenwang1 authored and richardweinberger committed Sep 15, 2019
1 parent 8615b94 commit ce4d8b1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/ubifs/tnc_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ce4d8b1

Please sign in to comment.