summaryrefslogtreecommitdiff
path: root/ubifs-utils/mkfs.ubifs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-10 13:46:21 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-10 15:29:53 +0100
commit64e9543eea4089aaf2bcae7f2b3b62b97bbe202f (patch)
treeabee992b1d76ed88f5ab99f175cdd6ee5fea8529 /ubifs-utils/mkfs.ubifs
parent1538c553302dae1df9088ec302a5b2fb5a15174f (diff)
mkfs.ubifs: free derived fscrypt context in add_directory error paths
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs')
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index ea0afee..87f7b4f 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -2099,24 +2099,32 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
if (S_ISDIR(dent_st.st_mode)) {
err = add_directory(name, inum, &dent_st, 1, new_fctx);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
nlink += 1;
type = UBIFS_ITYPE_DIR;
} else {
err = add_non_dir(name, &inum, 0, &type,
&dent_st, new_fctx);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
}
err = create_inum_attr(inum, name);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
err = add_dent_node(dir_inum, entry->d_name, inum, type, fctx);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
size += ALIGN(UBIFS_DENT_NODE_SZ + strlen(entry->d_name) + 1,
8);
@@ -2162,24 +2170,33 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st,
if (S_ISDIR(nh_elt->mode)) {
err = add_directory(name, inum, &fake_st, 0, new_fctx);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
nlink += 1;
type = UBIFS_ITYPE_DIR;
} else {
err = add_non_dir(name, &inum, 0, &type,
&fake_st, new_fctx);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
}
err = create_inum_attr(inum, name);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
err = add_dent_node(dir_inum, nh_elt->name, inum, type, fctx);
- if (err)
+ if (err) {
+ free_fscrypt_context(new_fctx);
goto out_free;
+ }
+
size += ALIGN(UBIFS_DENT_NODE_SZ + strlen(nh_elt->name) + 1, 8);
nh_elt = next_name_htbl_element(ph_elt, &itr);