提交 7992e004 编写于 作者: W Wenwen Wang 提交者: Richard Weinberger

ubifs: Fix memory leak in __ubifs_node_verify_hmac error path

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: 49525e5e ("ubifs: Add helper functions for authentication support")
Signed-off-by: NWenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: NRichard Weinberger <richard@nod.at>
上级 ce4d8b16
...@@ -479,8 +479,10 @@ int __ubifs_node_verify_hmac(const struct ubifs_info *c, const void *node, ...@@ -479,8 +479,10 @@ int __ubifs_node_verify_hmac(const struct ubifs_info *c, const void *node,
return -ENOMEM; return -ENOMEM;
err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac); err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac);
if (err) if (err) {
kfree(hmac);
return err; return err;
}
err = crypto_memneq(hmac, node + ofs_hmac, hmac_len); err = crypto_memneq(hmac, node + ofs_hmac, hmac_len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册