Skip to content

Commit

Permalink
Merge pull request #348 from Bolodya1997/qfix/ns-leak
Browse files Browse the repository at this point in the history
[qfix] Fix leaking ns handles
  • Loading branch information
denis-tingaikin authored Oct 12, 2021
2 parents 7f6e57f + ee15aea commit 880db40
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 880db40

Please sign in to comment.