Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 49525e5eecca ("ubifs: Add helper functions for authentication support")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Wenwen Wang and committed by
Richard Weinberger
7992e004 ce4d8b16

+3 -1
+3 -1
fs/ubifs/auth.c
··· 479 479 return -ENOMEM; 480 480 481 481 err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac); 482 - if (err) 482 + if (err) { 483 + kfree(hmac); 483 484 return err; 485 + } 484 486 485 487 err = crypto_memneq(hmac, node + ofs_hmac, hmac_len); 486 488