From feff5671267218af95218d6448e6f695374f22bb Mon Sep 17 00:00:00 2001 From: Mikhail Dmitrichenko Date: Wed, 24 Jun 2026 12:32:15 +0300 Subject: [PATCH] checkpoint: close rootfs tar stream after use chrootarchive.Tar returns an io.ReadCloser backed by a pipe to the tar-producing process. CRCreateRootFsDiffTar copies from the stream but never closes it. On the successful path the stream is read to EOF, so the producer normally exits. On early errors, such as failing to create the destination file or failing while copying to it, the producer can be left without a consumer. Close the tar stream after it is created so error paths release the pipe and allow the producer to exit. Signed-off-by: Mikhail Dmitrichenko --- pkg/checkpoint/crutils/checkpoint_restore_utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/checkpoint/crutils/checkpoint_restore_utils.go b/pkg/checkpoint/crutils/checkpoint_restore_utils.go index 2ac9f65079..cb9dd6ec1d 100644 --- a/pkg/checkpoint/crutils/checkpoint_restore_utils.go +++ b/pkg/checkpoint/crutils/checkpoint_restore_utils.go @@ -166,6 +166,7 @@ func CRCreateRootFsDiffTar(changes *[]archive.Change, mountPoint, destination st if err != nil { return includeFiles, fmt.Errorf("exporting root file-system diff to %q: %w", rootfsDiffPath, err) } + defer rootfsTar.Close() rootfsDiffFile, err := os.Create(rootfsDiffPath) if err != nil { return includeFiles, fmt.Errorf("creating root file-system diff file %q: %w", rootfsDiffPath, err)