Skip to content

Commit 47f6d9c

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubifs: Fix a memleak after dumping authentication mount options
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>
1 parent b30e223 commit 47f6d9c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

fs/ubifs/super.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,18 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
11411141
return 0;
11421142
}
11431143

1144+
/*
1145+
* ubifs_release_options - release mount parameters which have been dumped.
1146+
* @c: UBIFS file-system description object
1147+
*/
1148+
static void ubifs_release_options(struct ubifs_info *c)
1149+
{
1150+
kfree(c->auth_key_name);
1151+
c->auth_key_name = NULL;
1152+
kfree(c->auth_hash_name);
1153+
c->auth_hash_name = NULL;
1154+
}
1155+
11441156
/**
11451157
* destroy_journal - destroy journal data structures.
11461158
* @c: UBIFS file-system description object
@@ -1650,8 +1662,7 @@ static void ubifs_umount(struct ubifs_info *c)
16501662
ubifs_lpt_free(c, 0);
16511663
ubifs_exit_authentication(c);
16521664

1653-
kfree(c->auth_key_name);
1654-
kfree(c->auth_hash_name);
1665+
ubifs_release_options(c);
16551666
kfree(c->cbuf);
16561667
kfree(c->rcvrd_mst_node);
16571668
kfree(c->mst_node);
@@ -2219,6 +2230,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
22192230
out_unlock:
22202231
mutex_unlock(&c->umount_mutex);
22212232
out_close:
2233+
ubifs_release_options(c);
22222234
ubi_close_volume(c->ubi);
22232235
out:
22242236
return err;

0 commit comments

Comments
 (0)