diff --git a/pkg/networkutils/network.go b/pkg/networkutils/network.go index 7843b0f6e8..1899312c7e 100644 --- a/pkg/networkutils/network.go +++ b/pkg/networkutils/network.go @@ -381,12 +381,13 @@ func (n *linuxNetwork) setProcSys(key, value string) error { if err != nil { return err } - defer f.Close() _, err = f.WriteString(value) if err != nil { + // If the write failed, just close + _ = f.Close() return err } - return nil + return f.Close() } type iptablesRule struct {