1
0
Fork 0

ubifs: Fix a memleak after dumping authentication mount options

commit 47f6d9ce45 upstream.

Fix a memory leak after dumping authentication mount options in error
handling branch.

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: <stable@vger.kernel.org>  # 4.20+
Fixes: d8a22773a1 ("ubifs: Enable authentication support")
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5.4-rM2-2.2.x-imx-squashed
Zhihao Cheng 2020-09-29 20:45:29 +08:00 committed by Greg Kroah-Hartman
parent bc202c839b
commit 748057df47
1 changed files with 14 additions and 2 deletions

View File

@ -1123,6 +1123,18 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
return 0;
}
/*
* ubifs_release_options - release mount parameters which have been dumped.
* @c: UBIFS file-system description object
*/
static void ubifs_release_options(struct ubifs_info *c)
{
kfree(c->auth_key_name);
c->auth_key_name = NULL;
kfree(c->auth_hash_name);
c->auth_hash_name = NULL;
}
/**
* destroy_journal - destroy journal data structures.
* @c: UBIFS file-system description object
@ -1632,8 +1644,7 @@ static void ubifs_umount(struct ubifs_info *c)
ubifs_lpt_free(c, 0);
ubifs_exit_authentication(c);
kfree(c->auth_key_name);
kfree(c->auth_hash_name);
ubifs_release_options(c);
kfree(c->cbuf);
kfree(c->rcvrd_mst_node);
kfree(c->mst_node);
@ -2201,6 +2212,7 @@ out_umount:
out_unlock:
mutex_unlock(&c->umount_mutex);
out_close:
ubifs_release_options(c);
ubi_close_volume(c->ubi);
out:
return err;