]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:16 +0000 (07:21 -0500)
[ Upstream commit ca27313fb3f23e4ac18532ede4ec1c7cc5814c4a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/xfs/scrub/common.c
fs/xfs/scrub/repair.c
fs/xfs/scrub/scrub.c

index e6145c2eda02a5cce49ff2679ff4bfa21af3cbba..975c879c8d7f5df77360bb8979e6f11a2d4c9239 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 efd5a7ccdf624a1d762ab81621e219e2a0db2310..4d45d39e67f11e3e3c91b564f92a3fac21af5283 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 3c3b0d25006ff4a0224657bacbcf67d570da7f4a..c312f0a672e65ffbc671fa54bc7067104e9c4d9c 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;