]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: only call xf{array,blob}_destroy if we have a valid pointer
authorDarrick J. Wong <djwong@kernel.org>
Fri, 23 Jan 2026 17:27:37 +0000 (09:27 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Sat, 24 Jan 2026 16:46:36 +0000 (08:46 -0800)
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: ab97f4b1c03075 ("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>
fs/xfs/scrub/agheader_repair.c
fs/xfs/scrub/attr_repair.c
fs/xfs/scrub/dir_repair.c
fs/xfs/scrub/dirtree.c
fs/xfs/scrub/nlinks.c

index d8e3c51a41b1a4c0a4bbf44c2d2fbd6364dffd03..15d58eedb38735884c064b71395d18e61a2d2301 100644 (file)
@@ -837,8 +837,12 @@ xrep_agi_buf_cleanup(
 {
        struct xrep_agi *ragi = buf;
 
-       xfarray_destroy(ragi->iunlink_prev);
-       xfarray_destroy(ragi->iunlink_next);
+       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);
 }
 
index f9191eae13eea6e7dcb3529e9b8f4b5f0a0076d7..a924b467a8447a0ca4cccad01d7029522c5c12bf 100644 (file)
@@ -1516,8 +1516,10 @@ xrep_xattr_teardown(
                xfblob_destroy(rx->pptr_names);
        if (rx->pptr_recs)
                xfarray_destroy(rx->pptr_recs);
-       xfblob_destroy(rx->xattr_blobs);
-       xfarray_destroy(rx->xattr_records);
+       if (rx->xattr_blobs)
+               xfblob_destroy(rx->xattr_blobs);
+       if (rx->xattr_records)
+               xfarray_destroy(rx->xattr_records);
        mutex_destroy(&rx->lock);
        kfree(rx);
 }
index dbfcef6fb7da65a928e7fa396f9d7bb6c1d49296..f105e49f654bd12028b73a95d4068946e0b8688b 100644 (file)
@@ -172,8 +172,12 @@ xrep_dir_teardown(
        struct xrep_dir         *rd = sc->buf;
 
        xrep_findparent_scan_teardown(&rd->pscan);
-       xfblob_destroy(rd->dir_names);
-       xfarray_destroy(rd->dir_entries);
+       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. */
index e484f8a0886cd45d42671222fba64fa2d04e3fd9..e95dc74f1145692e17194ef0abf441f7f78928e4 100644 (file)
@@ -81,8 +81,12 @@ xchk_dirtree_buf_cleanup(
                kfree(path);
        }
 
-       xfblob_destroy(dl->path_names);
-       xfarray_destroy(dl->path_steps);
+       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);
 }
 
index 46488aff908ccfdd715bdb3b557e085fc6de180a..e80fe7395d788095693d1467a122ec2da12979eb 100644 (file)
@@ -971,7 +971,8 @@ xchk_nlinks_teardown_scan(
 
        xfs_dir_hook_del(xnc->sc->mp, &xnc->dhook);
 
-       xfarray_destroy(xnc->nlinks);
+       if (xnc->nlinks)
+               xfarray_destroy(xnc->nlinks);
        xnc->nlinks = NULL;
 
        xchk_iscan_teardown(&xnc->collect_iscan);