summaryrefslogtreecommitdiff
path: root/fs/ext4/ext4_write.c
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-06 04:36:42 +0200
committerTom Rini <trini@konsulko.com>2016-09-23 09:02:35 -0400
commita0d767e2c1e40e781fdaa592f06f92614b4e5cdf (patch)
tree17aacbdac487f13d52ba2cc182df55fef108e1d5 /fs/ext4/ext4_write.c
parent76a29519ff87dd6a014d841a3a6e501d3b2f5153 (diff)
downloadu-boot-a0d767e2c1e40e781fdaa592f06f92614b4e5cdf.tar.gz
ext4: propagate error if creation of directory entry fails
In case the dir entry creation failed, ext4fs_write would later overwrite a random inode, as inodeno was never initialized. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Diffstat (limited to 'fs/ext4/ext4_write.c')
-rw-r--r--fs/ext4/ext4_write.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 9200c4727e..a52804e8e1 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -907,7 +907,9 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
goto fail;
}
- ext4fs_update_parent_dentry(filename, &inodeno, FILETYPE_REG);
+ inodeno = ext4fs_update_parent_dentry(filename, FILETYPE_REG);
+ if (inodeno == -1)
+ goto fail;
/* prepare file inode */
inode_buffer = zalloc(fs->inodesz);
if (!inode_buffer)