Skip to content

Commit

Permalink
Fix leaking ns handles
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <[email protected]>
  • Loading branch information
Vladimir Popov committed Oct 12, 2021
1 parent 7f6e57f commit ee15aea
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/kernel/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func FindHostDevice(pciAddress, name string, namespaces ...netns.NsHandle) (Link
if err := netns.Set(current); err != nil {
panic(errors.Wrapf(err, "failed to switch back to the current net NS: %v", current).Error())
}
_ = current.Close()
}()

attempts := []func(netns.NsHandle, string, string) (netlink.Link, error){
Expand Down Expand Up @@ -259,6 +260,7 @@ func GetNetlinkHandle(urlString string) (*netlink.Handle, error) {
if err != nil {
return nil, errors.WithStack(err)
}
defer func() { _ = curNSHandle.Close() }()

nsHandle, err := nshandle.FromURL(urlString)
if err != nil {
Expand Down

0 comments on commit ee15aea

Please sign in to comment.