Skip to content

Commit

Permalink
ubifs: Fix memory leak in __ubifs_node_verify_hmac error path
Browse files Browse the repository at this point in the history
In __ubifs_node_verify_hmac(), 'hmac' is allocated through kmalloc().
However, it is not deallocated in the following execution if
ubifs_node_calc_hmac() fails, leading to a memory leak bug. To fix this
issue, free 'hmac' before returning the error.

Fixes: 49525e5 ("ubifs: Add helper functions for authentication support")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
wenwenwang1 authored and richardweinberger committed Sep 15, 2019
1 parent ce4d8b1 commit 7992e00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/ubifs/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,10 @@ int __ubifs_node_verify_hmac(const struct ubifs_info *c, const void *node,
return -ENOMEM;

err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac);
if (err)
if (err) {
kfree(hmac);
return err;
}

err = crypto_memneq(hmac, node + ofs_hmac, hmac_len);

Expand Down

0 comments on commit 7992e00

Please sign in to comment.