Skip to content

Commit

Permalink
Ignore errcheck: error return value of unix.Unmount is not checked
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Rodák <[email protected]>
  • Loading branch information
Honny1 committed Jul 8, 2024
1 parent f185be6 commit 3399c82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion drivers/overlay/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3399c82

Please sign in to comment.