]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: don't leak phase 5 scan items after a failed workqueue_add
authorDarrick J. Wong <djwong@kernel.org>
Tue, 9 Jun 2026 16:49:22 +0000 (09:49 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jun 2026 00:57:06 +0000 (17:57 -0700)
Codex points out that queue_metapath_scan and queue_fs_scan fail to free
the allocated items if they are not consumed by workqueue_add().

Cc: <linux-xfs@vger.kernel.org> # v6.9.0
Fixes: 8fb4b471322e65 ("xfs_scrub: use multiple threads to run in-kernel metadata scrubs that scan inodes")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/phase5.c

index 329d208d882ef13cb3a9c98980b69336cf1c8474..fd1b70332deeee9830c8f70253ad37140795b84d 100644 (file)
@@ -687,8 +687,10 @@ queue_fs_scan(
        item->abortedp = abortedp;
 
        ret = -workqueue_add(wq, fs_scan_worker, nr, item);
-       if (ret)
+       if (ret) {
                str_liberror(ctx, ret, _("queuing fs scan work"));
+               free(item);
+       }
 
        return ret;
 }
@@ -764,8 +766,10 @@ queue_metapath_scan(
        item->abortedp = abortedp;
 
        ret = -workqueue_add(wq, fs_scan_worker, 0, item);
-       if (ret)
+       if (ret) {
                str_liberror(ctx, ret, _("queuing metapath scan work"));
+               free(item);
+       }
 
        return ret;
 }