Skip to content

Commit

Permalink
xfs: fix uninitialized list head in struct xfs_refcount_recovery
Browse files Browse the repository at this point in the history
We're supposed to initialize the list head of an object before adding it
to another list.  Fix that, and stop using the kmem_{alloc,free} calls
from the Irix days.

Fixes: 174edb0 ("xfs: store in-progress CoW allocations in the refcount btree")
Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
  • Loading branch information
Darrick J. Wong committed Oct 31, 2022
1 parent f1fdc82 commit c1ccf96
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/xfs/libxfs/xfs_refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,12 +1767,14 @@ xfs_refcount_recover_extent(
be32_to_cpu(rec->refc.rc_refcount) != 1))
return -EFSCORRUPTED;

rr = kmem_alloc(sizeof(struct xfs_refcount_recovery), 0);
rr = kmalloc(sizeof(struct xfs_refcount_recovery),
GFP_KERNEL | __GFP_NOFAIL);
INIT_LIST_HEAD(&rr->rr_list);
xfs_refcount_btrec_to_irec(rec, &rr->rr_rrec);

if (XFS_IS_CORRUPT(cur->bc_mp,
rr->rr_rrec.rc_domain != XFS_REFC_DOMAIN_COW)) {
kmem_free(rr);
kfree(rr);
return -EFSCORRUPTED;
}

Expand Down Expand Up @@ -1859,7 +1861,7 @@ xfs_refcount_recover_cow_leftovers(
goto out_free;

list_del(&rr->rr_list);
kmem_free(rr);
kfree(rr);
}

return error;
Expand All @@ -1869,7 +1871,7 @@ xfs_refcount_recover_cow_leftovers(
/* Free the leftover list */
list_for_each_entry_safe(rr, n, &debris, rr_list) {
list_del(&rr->rr_list);
kmem_free(rr);
kfree(rr);
}
return error;
}
Expand Down

0 comments on commit c1ccf96

Please sign in to comment.