Skip to content

Commit bb3d48d

Browse files
sandeendjwong
authored andcommitted
xfs: don't call xfs_da_shrink_inode with NULL bp
xfs_attr3_leaf_create may have errored out before instantiating a buffer, for example if the blkno is out of range. In that case there is no work to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops if we try. This also seems to fix a flaw where the original error from xfs_attr3_leaf_create gets overwritten in the cleanup case, and it removes a pointless assignment to bp which isn't used after this. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969 Reported-by: Xu, Wen <wen.xu@gatech.edu> Tested-by: Xu, Wen <wen.xu@gatech.edu> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
1 parent 9bb54cb commit bb3d48d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Diff for: fs/xfs/libxfs/xfs_attr_leaf.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,8 @@ xfs_attr_shortform_to_leaf(
791791
ASSERT(blkno == 0);
792792
error = xfs_attr3_leaf_create(args, blkno, &bp);
793793
if (error) {
794-
error = xfs_da_shrink_inode(args, 0, bp);
795-
bp = NULL;
796-
if (error)
794+
/* xfs_attr3_leaf_create may not have instantiated a block */
795+
if (bp && (xfs_da_shrink_inode(args, 0, bp) != 0))
797796
goto out;
798797
xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */
799798
memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */

0 commit comments

Comments
 (0)