From: Wenwen Wang Date: Tue, 20 Aug 2019 03:24:50 +0000 (-0500) Subject: ubifs: Fix memory leak in __ubifs_node_verify_hmac error path X-Git-Tag: v5.4-rc1~85^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7992e00469c485f108a7f0da08be34b0fa441f79;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Richard Weinberger --- diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c index d9af2de..8cdbd53 100644 --- a/fs/ubifs/auth.c +++ b/fs/ubifs/auth.c @@ -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);