]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
udf: Handle error when expanding directory
authorJan Kara <jack@suse.cz>
Thu, 17 Oct 2024 20:20:00 +0000 (17:20 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Oct 2024 13:40:39 +0000 (15:40 +0200)
[ Upstream commit 33e9a53cd9f099b138578f8e1a3d60775ff8cbba ]

When there is an error when adding extent to the directory to expand it,
make sure to propagate the error up properly. This is not expected to
happen currently but let's make the code more futureproof.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/udf/namei.c

index 21a9761547790ae62de8b278a294a77b3dc75fc2..ced58595a474b901e7d1ce1f0cc9b85c49825590 100644 (file)
@@ -192,8 +192,13 @@ static struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
        epos.bh = NULL;
        epos.block = iinfo->i_location;
        epos.offset = udf_file_entry_alloc_offset(inode);
-       udf_add_aext(inode, &epos, &eloc, inode->i_size, 0);
+       ret = udf_add_aext(inode, &epos, &eloc, inode->i_size, 0);
        brelse(epos.bh);
+       if (ret < 0) {
+               *err = ret;
+               udf_free_blocks(inode->i_sb, inode, &eloc, 0, 1);
+               return NULL;
+       }
        mark_inode_dirty(inode);
 
        /* Now fixup tags in moved directory entries */