Skip to content

Commit ba408d2

Browse files
author
Darrick J. Wong
committed
xfs: only call xf{array,blob}_destroy if we have a valid pointer
Only call the xfarray and xfblob destructor if we have a valid pointer, and be sure to null out that pointer afterwards. Note that this patch fixes a large number of commits, most of which were merged between 6.9 and 6.10. Cc: r772577952@gmail.com Cc: <stable@vger.kernel.org> # v6.12 Fixes: ab97f4b ("xfs: repair AGI unlinked inode bucket lists") Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Tested-by: Jiaming Zhang <r772577952@gmail.com>
1 parent 6038299 commit ba408d2

5 files changed

Lines changed: 24 additions & 9 deletions

File tree

fs/xfs/scrub/agheader_repair.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,12 @@ xrep_agi_buf_cleanup(
837837
{
838838
struct xrep_agi *ragi = buf;
839839

840-
xfarray_destroy(ragi->iunlink_prev);
841-
xfarray_destroy(ragi->iunlink_next);
840+
if (ragi->iunlink_prev)
841+
xfarray_destroy(ragi->iunlink_prev);
842+
ragi->iunlink_prev = NULL;
843+
if (ragi->iunlink_next)
844+
xfarray_destroy(ragi->iunlink_next);
845+
ragi->iunlink_next = NULL;
842846
xagino_bitmap_destroy(&ragi->iunlink_bmp);
843847
}
844848

fs/xfs/scrub/attr_repair.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,10 @@ xrep_xattr_teardown(
15161516
xfblob_destroy(rx->pptr_names);
15171517
if (rx->pptr_recs)
15181518
xfarray_destroy(rx->pptr_recs);
1519-
xfblob_destroy(rx->xattr_blobs);
1520-
xfarray_destroy(rx->xattr_records);
1519+
if (rx->xattr_blobs)
1520+
xfblob_destroy(rx->xattr_blobs);
1521+
if (rx->xattr_records)
1522+
xfarray_destroy(rx->xattr_records);
15211523
mutex_destroy(&rx->lock);
15221524
kfree(rx);
15231525
}

fs/xfs/scrub/dir_repair.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,12 @@ xrep_dir_teardown(
172172
struct xrep_dir *rd = sc->buf;
173173

174174
xrep_findparent_scan_teardown(&rd->pscan);
175-
xfblob_destroy(rd->dir_names);
176-
xfarray_destroy(rd->dir_entries);
175+
if (rd->dir_names)
176+
xfblob_destroy(rd->dir_names);
177+
rd->dir_names = NULL;
178+
if (rd->dir_entries)
179+
xfarray_destroy(rd->dir_entries);
180+
rd->dir_names = NULL;
177181
}
178182

179183
/* Set up for a directory repair. */

fs/xfs/scrub/dirtree.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ xchk_dirtree_buf_cleanup(
8181
kfree(path);
8282
}
8383

84-
xfblob_destroy(dl->path_names);
85-
xfarray_destroy(dl->path_steps);
84+
if (dl->path_names)
85+
xfblob_destroy(dl->path_names);
86+
dl->path_names = NULL;
87+
if (dl->path_steps)
88+
xfarray_destroy(dl->path_steps);
89+
dl->path_steps = NULL;
8690
mutex_destroy(&dl->lock);
8791
}
8892

fs/xfs/scrub/nlinks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,8 @@ xchk_nlinks_teardown_scan(
971971

972972
xfs_dir_hook_del(xnc->sc->mp, &xnc->dhook);
973973

974-
xfarray_destroy(xnc->nlinks);
974+
if (xnc->nlinks)
975+
xfarray_destroy(xnc->nlinks);
975976
xnc->nlinks = NULL;
976977

977978
xchk_iscan_teardown(&xnc->collect_iscan);

0 commit comments

Comments
 (0)