From 9d18ca1505f51d8d979850166c2954a4c23239fb Mon Sep 17 00:00:00 2001 From: lifubang Date: Tue, 18 Nov 2025 04:53:19 +0000 Subject: [PATCH] libct: add a defer fd close in createDeviceNode Signed-off-by: lifubang (cherry picked from commit 9a5e6262f0bf4e3e654b1a0d71bb804093948f85) Signed-off-by: lifubang --- libcontainer/rootfs_linux.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go index 151ca9a58..680b69ce9 100644 --- a/libcontainer/rootfs_linux.go +++ b/libcontainer/rootfs_linux.go @@ -997,6 +997,8 @@ func createDeviceNode(rootfs string, node *devices.Device, bind bool) error { if err != nil { return fmt.Errorf("mkdir parent of device inode %q: %w", node.Path, err) } + defer destDir.Close() + if bind { return bindMountDeviceNode(destDir, destName, node) }