Skip to content

Commit ca27313

Browse files
author
Darrick J. Wong
committed
xfs: check return value of xchk_scrub_create_subord
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: 1a5f6e0 ("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>
1 parent ba408d2 commit ca27313

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

fs/xfs/scrub/common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,9 @@ xchk_metadata_inode_subtype(
13991399
int error;
14001400

14011401
sub = xchk_scrub_create_subord(sc, scrub_type);
1402+
if (!sub)
1403+
return -ENOMEM;
1404+
14021405
error = sub->sc.ops->scrub(&sub->sc);
14031406
xchk_scrub_free_subord(sub);
14041407
return error;

fs/xfs/scrub/repair.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,9 @@ xrep_metadata_inode_subtype(
11361136
* setup/teardown routines.
11371137
*/
11381138
sub = xchk_scrub_create_subord(sc, scrub_type);
1139+
if (!sub)
1140+
return -ENOMEM;
1141+
11391142
error = sub->sc.ops->scrub(&sub->sc);
11401143
if (error)
11411144
goto out;

fs/xfs/scrub/scrub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ xchk_scrub_create_subord(
634634

635635
sub = kzalloc(sizeof(*sub), XCHK_GFP_FLAGS);
636636
if (!sub)
637-
return ERR_PTR(-ENOMEM);
637+
return NULL;
638638

639639
sub->old_smtype = sc->sm->sm_type;
640640
sub->old_smflags = sc->sm->sm_flags;

0 commit comments

Comments
 (0)