On 26 Mar 2021 at 06:03, Allison Henderson wrote: > This patch hoists the later half of xfs_attr_node_addname into > the calling function. We do this because it is this area that > will need the most state management, and we want to keep such > code in the same scope as much as possible > > Signed-off-by: Allison Henderson <allison.henderson@xxxxxxxxxx> > Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx> > Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx> > --- > fs/xfs/libxfs/xfs_attr.c | 161 +++++++++++++++++++++++------------------------ > 1 file changed, 78 insertions(+), 83 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c > index 16159f6..5b5410f 100644 > --- a/fs/xfs/libxfs/xfs_attr.c > +++ b/fs/xfs/libxfs/xfs_attr.c > @@ -52,6 +52,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); > * Internal routines when attribute list is more than one block. > */ > STATIC int xfs_attr_node_get(xfs_da_args_t *args); > +STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); > STATIC int xfs_attr_node_addname(struct xfs_da_args *args, > struct xfs_da_state *state); > STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, > @@ -270,8 +271,8 @@ xfs_attr_set_args( > struct xfs_da_args *args) > { > struct xfs_inode *dp = args->dp; > - struct xfs_da_state *state; > - int error; > + struct xfs_da_state *state = NULL; > + int error = 0; > > /* > * If the attribute list is already in leaf format, jump straight to > @@ -322,8 +323,79 @@ xfs_attr_set_args( > return error; > error = xfs_attr_node_addname(args, state); > } while (error == -EAGAIN); > + if (error) > + return error; Memory pointed to by 'state' is leaked if the call to either xfs_da3_split() or xfs_defer_finish() inside xfs_attr_node_addname() return an error. -- chandan