From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752724AbdFUVWY (ORCPT ); Wed, 21 Jun 2017 17:22:24 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:36040 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbdFUVWV (ORCPT ); Wed, 21 Jun 2017 17:22:21 -0400 From: Tahsin Erdogan To: Andreas Dilger , "Darrick J . Wong" , Jan Kara , "Theodore Ts'o" , linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH 19/32] ext4: ext4_xattr_delete_inode() should return accurate errors Date: Wed, 21 Jun 2017 14:21:29 -0700 Message-Id: <20170621212142.16581-19-tahsin@google.com> X-Mailer: git-send-email 2.13.1.611.g7e3b11ae1-goog In-Reply-To: <20170621212142.16581-1-tahsin@google.com> References: <20170621212142.16581-1-tahsin@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In a few places the function returns without trying to pass the actual error code to the caller. Fix those. Signed-off-by: Tahsin Erdogan --- fs/ext4/xattr.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 0dfae3f8e209..97d33ecf0818 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2026,7 +2026,8 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, if (!entry->e_value_inum) continue; ea_ino = le32_to_cpu(entry->e_value_inum); - if (ext4_expand_ino_array(lea_ino_array, ea_ino) != 0) { + error = ext4_expand_ino_array(lea_ino_array, ea_ino); + if (error) { brelse(iloc.bh); goto cleanup; } @@ -2037,20 +2038,22 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, delete_external_ea: if (!EXT4_I(inode)->i_file_acl) { /* add xattr inode to orphan list */ - ext4_xattr_inode_orphan_add(handle, inode, credits, - *lea_ino_array); + error = ext4_xattr_inode_orphan_add(handle, inode, credits, + *lea_ino_array); goto cleanup; } bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); if (!bh) { EXT4_ERROR_INODE(inode, "block %llu read error", EXT4_I(inode)->i_file_acl); + error = -EIO; goto cleanup; } if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || BHDR(bh)->h_blocks != cpu_to_le32(1)) { EXT4_ERROR_INODE(inode, "bad block %llu", EXT4_I(inode)->i_file_acl); + error = -EFSCORRUPTED; goto cleanup; } @@ -2059,7 +2062,8 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, if (!entry->e_value_inum) continue; ea_ino = le32_to_cpu(entry->e_value_inum); - if (ext4_expand_ino_array(lea_ino_array, ea_ino) != 0) + error = ext4_expand_ino_array(lea_ino_array, ea_ino); + if (error) goto cleanup; entry->e_value_inum = 0; } @@ -2067,7 +2071,7 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, /* add xattr inode to orphan list */ error = ext4_xattr_inode_orphan_add(handle, inode, credits, *lea_ino_array); - if (error != 0) + if (error) goto cleanup; if (!IS_NOQUOTA(inode)) @@ -2077,7 +2081,7 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, error = ext4_journal_extend(handle, credits); if (error > 0) error = ext4_journal_restart(handle, credits); - if (error != 0) { + if (error) { ext4_warning(inode->i_sb, "couldn't extend journal (err %d)", error); goto cleanup; -- 2.13.1.611.g7e3b11ae1-goog