From 3399c822a370fbbb04ba2062489c430f578daac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Wed, 3 Jul 2024 13:00:49 +0200 Subject: [PATCH] Ignore errcheck: error return value of `unix.Unmount` is not checked MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- drivers/overlay/check.go | 4 +++- drivers/overlay/overlay.go | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/overlay/check.go b/drivers/overlay/check.go index d8139f6566..db8d13353e 100644 --- a/drivers/overlay/check.go +++ b/drivers/overlay/check.go @@ -263,7 +263,9 @@ func supportsIdmappedLowerLayers(home string) (bool, error) { if err := idmap.CreateIDMappedMount(lowerDir, lowerMappedDir, int(pid)); err != nil { return false, fmt.Errorf("create mapped mount: %w", err) } - defer unix.Unmount(lowerMappedDir, unix.MNT_DETACH) + defer func() { + _ = unix.Unmount(lowerMappedDir, unix.MNT_DETACH) + }() opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerMappedDir, upperDir, workDir) flags := uintptr(0) diff --git a/drivers/overlay/overlay.go b/drivers/overlay/overlay.go index 0585228981..c30b51c7af 100644 --- a/drivers/overlay/overlay.go +++ b/drivers/overlay/overlay.go @@ -1553,7 +1553,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO composefsMounts := []string{} defer func() { for _, m := range composefsMounts { - defer unix.Unmount(m, unix.MNT_DETACH) + defer func(m string) { + _ = unix.Unmount(m, unix.MNT_DETACH) + }(m) } }() @@ -1657,7 +1659,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO skipIDMappingLayers[composefsMount] = composefsMount // overlay takes a reference on the mount, so it is safe to unmount // the mapped idmounts as soon as the final overlay file system is mounted. - defer unix.Unmount(composefsMount, unix.MNT_DETACH) + defer func() { + _ = unix.Unmount(composefsMount, unix.MNT_DETACH) + }() } absLowers = append(absLowers, composefsMount) continue @@ -1764,7 +1768,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO // overlay takes a reference on the mount, so it is safe to unmount // the mapped idmounts as soon as the final overlay file system is mounted. - defer unix.Unmount(root, unix.MNT_DETACH) + defer func() { + _ = unix.Unmount(root, unix.MNT_DETACH) + }() } // relative path to the layer through the id mapped mount