]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: check return value of xchk_scrub_create_subord
authorDarrick J. Wong <djwong@kernel.org>
Fri, 23 Jan 2026 17:27:38 +0000 (09:27 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Sat, 24 Jan 2026 16:46:38 +0000 (08:46 -0800)
Fix this function to return NULL instead of a mangled ENOMEM, then fix
the callers to actually check for a null pointer and return ENOMEM.
Most of the corrections here are for code merged between 6.2 and 6.10.

Cc: r772577952@gmail.com
Cc: <stable@vger.kernel.org> # v6.12
Fixes: 1a5f6e08d4e379 ("xfs: create subordinate scrub contexts for xchk_metadata_inode_subtype")
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/common.c
fs/xfs/scrub/repair.c
fs/xfs/scrub/scrub.c

index affed35a8c96fd74ff9f96afdfc8db43778842df..20e63069088b397ab04127d15f21ae85a7a8a6d0 100644 (file)
@@ -1399,6 +1399,9 @@ xchk_metadata_inode_subtype(
        int                     error;
 
        sub = xchk_scrub_create_subord(sc, scrub_type);
+       if (!sub)
+               return -ENOMEM;
+
        error = sub->sc.ops->scrub(&sub->sc);
        xchk_scrub_free_subord(sub);
        return error;
index 3ebe27524ce397d5530a4fb4495d3fe5ee0a4dc0..ac8c592579bd50a6da38a0dbe73c60ef607e3d55 100644 (file)
@@ -1136,6 +1136,9 @@ xrep_metadata_inode_subtype(
         * setup/teardown routines.
         */
        sub = xchk_scrub_create_subord(sc, scrub_type);
+       if (!sub)
+               return -ENOMEM;
+
        error = sub->sc.ops->scrub(&sub->sc);
        if (error)
                goto out;
index 670ac2baae0c74b0d3ee70c46741e5c8a3835647..c1c6415f5055069427b0c3191c32d3377a157546 100644 (file)
@@ -634,7 +634,7 @@ xchk_scrub_create_subord(
 
        sub = kzalloc(sizeof(*sub), XCHK_GFP_FLAGS);
        if (!sub)
-               return ERR_PTR(-ENOMEM);
+               return NULL;
 
        sub->old_smtype = sc->sm->sm_type;
        sub->old_smflags = sc->sm->sm_flags;