diff --git a/common/utils.go b/common/utils.go index 25130ab2..281699a6 100644 --- a/common/utils.go +++ b/common/utils.go @@ -130,6 +130,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo if err != nil { return nil, fmt.Errorf("unable to open root namespace: %s", err) } + defer nsToplevel.Close() nsContainr, err := netns.GetFromPid(processID) if err != nil { if os.IsNotExist(err) { @@ -137,6 +138,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo } return nil, fmt.Errorf("unable to open process %d namespace: %s", processID, err) } + defer nsContainr.Close() if nsToplevel.Equal(nsContainr) { return nil, nil }