Skip to content

Commit

Permalink
ubifs: Fix memleak in ubifs_init_authentication
Browse files Browse the repository at this point in the history
[ Upstream commit 11b8ab3 ]

When crypto_shash_digestsize() fails, c->hmac_tfm
has not been freed before returning, which leads
to memleak.

Fixes: 49525e5 ("ubifs: Add helper functions for authentication support")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dinghaoliu authored and gregkh committed Mar 4, 2021
1 parent c4ede75 commit 5501892
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ubifs/auth.c
Expand Up @@ -342,7 +342,7 @@ int ubifs_init_authentication(struct ubifs_info *c)
ubifs_err(c, "hmac %s is bigger than maximum allowed hmac size (%d > %d)",
hmac_name, c->hmac_desc_len, UBIFS_HMAC_ARR_SZ);
err = -EINVAL;
goto out_free_hash;
goto out_free_hmac;
}

err = crypto_shash_setkey(c->hmac_tfm, ukp->data, ukp->datalen);
Expand Down

0 comments on commit 5501892

Please sign in to comment.