From 3463f3c37560e3eaa3d408430cf8e24af67971a7 Mon Sep 17 00:00:00 2001 From: Odin Ugedal Date: Thu, 19 Sep 2019 11:35:12 +0200 Subject: [PATCH] Fix closing of dirs in doSafeMakeDir This fixes the issue where "childFD" from syscall.Openat is assigned to a local variable inside the for loop, instead of the correct one in the function scope. This results in that when trying to close the "childFD" in the function scope, it will be equal to "-1", instead of the correct value. --- .../legacy-cloud-providers/openstack/util/mount/mount_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go index 5dda471c6637..23a66539b560 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go @@ -1132,7 +1132,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { return fmt.Errorf("cannot create directory %s: %s", currentPath, err) } // Dive into the created directory - childFD, err := syscall.Openat(parentFD, dir, nofollowFlags, 0) + childFD, err = syscall.Openat(parentFD, dir, nofollowFlags, 0) if err != nil { return fmt.Errorf("cannot open %s: %s", currentPath, err) }