Skip to content

Commit

Permalink
ubifs: Fix a memleak after dumping authentication mount options
Browse files Browse the repository at this point in the history
commit 47f6d9c 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: d8a2277 ("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>
  • Loading branch information
Zhihao Cheng authored and gregkh committed Nov 5, 2020
1 parent 10185cb commit 92b2d13
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions fs/ubifs/super.c
Expand Up @@ -1141,6 +1141,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
Expand Down Expand Up @@ -1650,8 +1662,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);
Expand Down Expand Up @@ -2219,6 +2230,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
out_unlock:
mutex_unlock(&c->umount_mutex);
out_close:
ubifs_release_options(c);
ubi_close_volume(c->ubi);
out:
return err;
Expand Down

0 comments on commit 92b2d13

Please sign in to comment.