Skip to content

Commit a618aca

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: don't leak the retained da state when doing a leaf to node conversion
If a setxattr operation finds an xattr structure in leaf format, adding the attr can fail due to lack of space and hence requires an upgrade to node format. After this happens, we'll roll the transaction and re-enter the state machine, at which time we need to perform a second lookup of the attribute name to find its new location. This lookup attaches a new da state structure to the xfs_attr_item but doesn't free the old one (from the leaf lookup) and leaks it. Fix that. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent 309001c commit a618aca

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,10 @@ xfs_attr_node_hasname(
14011401
int retval, error;
14021402

14031403
state = xfs_da_state_alloc(args);
1404-
if (statep != NULL)
1404+
if (statep != NULL) {
1405+
ASSERT(*statep == NULL);
14051406
*statep = state;
1407+
}
14061408

14071409
/*
14081410
* Search to see if name exists, and get back a pointer to it.
@@ -1428,6 +1430,10 @@ xfs_attr_node_addname_find_attr(
14281430
struct xfs_da_args *args = attr->xattri_da_args;
14291431
int error;
14301432

1433+
if (attr->xattri_da_state)
1434+
xfs_da_state_free(attr->xattri_da_state);
1435+
attr->xattri_da_state = NULL;
1436+
14311437
/*
14321438
* Search to see if name already exists, and get back a pointer
14331439
* to where it should go.
@@ -1593,7 +1599,7 @@ STATIC int
15931599
xfs_attr_node_get(
15941600
struct xfs_da_args *args)
15951601
{
1596-
struct xfs_da_state *state;
1602+
struct xfs_da_state *state = NULL;
15971603
struct xfs_da_state_blk *blk;
15981604
int i;
15991605
int error;

0 commit comments

Comments
 (0)