Commit ba408d29 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

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: ab97f4b1 ("xfs: repair AGI unlinked inode bucket lists")
Signed-off-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Tested-by: default avatarJiaming Zhang <r772577952@gmail.com>
parent 60382993
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -837,8 +837,12 @@ xrep_agi_buf_cleanup(
{
	struct xrep_agi	*ragi = buf;

	if (ragi->iunlink_prev)
		xfarray_destroy(ragi->iunlink_prev);
	ragi->iunlink_prev = NULL;
	if (ragi->iunlink_next)
		xfarray_destroy(ragi->iunlink_next);
	ragi->iunlink_next = NULL;
	xagino_bitmap_destroy(&ragi->iunlink_bmp);
}

+4 −2
Original line number Diff line number Diff line
@@ -1516,7 +1516,9 @@ xrep_xattr_teardown(
		xfblob_destroy(rx->pptr_names);
	if (rx->pptr_recs)
		xfarray_destroy(rx->pptr_recs);
	if (rx->xattr_blobs)
		xfblob_destroy(rx->xattr_blobs);
	if (rx->xattr_records)
		xfarray_destroy(rx->xattr_records);
	mutex_destroy(&rx->lock);
	kfree(rx);
+6 −2
Original line number Diff line number Diff line
@@ -172,8 +172,12 @@ xrep_dir_teardown(
	struct xrep_dir		*rd = sc->buf;

	xrep_findparent_scan_teardown(&rd->pscan);
	if (rd->dir_names)
		xfblob_destroy(rd->dir_names);
	rd->dir_names = NULL;
	if (rd->dir_entries)
		xfarray_destroy(rd->dir_entries);
	rd->dir_names = NULL;
}

/* Set up for a directory repair. */
+6 −2
Original line number Diff line number Diff line
@@ -81,8 +81,12 @@ xchk_dirtree_buf_cleanup(
		kfree(path);
	}

	if (dl->path_names)
		xfblob_destroy(dl->path_names);
	dl->path_names = NULL;
	if (dl->path_steps)
		xfarray_destroy(dl->path_steps);
	dl->path_steps = NULL;
	mutex_destroy(&dl->lock);
}

+2 −1
Original line number Diff line number Diff line
@@ -971,6 +971,7 @@ xchk_nlinks_teardown_scan(

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

	if (xnc->nlinks)
		xfarray_destroy(xnc->nlinks);
	xnc->nlinks = NULL;