Subject: [PATCH 2171/2944] ext4: unlock xattr_sem properly in ext4_inline_data_truncate()

From: Joseph Qi <[email-masked]>
Date: Tue, 3 Nov 2020 10:29:02 +0800

to #31361888

commit 7067b2619017d51e71686ca9756b454de0e5826a upstream.

It takes xattr_sem to check inline data again but without unlock it
in case not have. So unlock it before return.

Fixes: aef1c8513c1f ("ext4: let ext4_truncate handle inline data correctly")
Reported-by: Dan Carpenter <[email-masked]>
Cc: Tao Ma <[email-masked]>
Signed-off-by: Joseph Qi <[email-masked]>
Reviewed-by: Andreas Dilger <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Signed-off-by: Theodore Ts'o <[email-masked]>
Cc: [email-masked]
Acked-by: Xiaoguang Wang <[email-masked]>
---
 fs/ext4/inline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 4572cb0..c952461 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1921,6 +1921,7 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline)
 
 	ext4_write_lock_xattr(inode, &no_expand);
 	if (!ext4_has_inline_data(inode)) {
+		ext4_write_unlock_xattr(inode, &no_expand);
 		*has_inline = 0;
 		ext4_journal_stop(handle);
 		return 0;
-- 
1.8.3.1