Skip to content

Commit

Permalink
xfs: cleanup error handling in xfs_buf_get_map
Browse files Browse the repository at this point in the history
Use a single goto label for freeing the buffer and returning an
error.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
Christoph Hellwig authored and dchinner committed Jun 7, 2021
1 parent 289ae7b commit 170041f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,16 +689,12 @@ xfs_buf_get_map(
return error;

error = xfs_buf_allocate_memory(new_bp, flags);
if (error) {
xfs_buf_free(new_bp);
return error;
}
if (error)
goto out_free_buf;

error = xfs_buf_find(target, map, nmaps, flags, new_bp, &bp);
if (error) {
xfs_buf_free(new_bp);
return error;
}
if (error)
goto out_free_buf;

if (bp != new_bp)
xfs_buf_free(new_bp);
Expand Down Expand Up @@ -726,6 +722,9 @@ xfs_buf_get_map(
trace_xfs_buf_get(bp, flags, _RET_IP_);
*bpp = bp;
return 0;
out_free_buf:
xfs_buf_free(new_bp);
return error;
}

int
Expand Down

0 comments on commit 170041f

Please sign in to comment.