diff --git a/pkg/bpf/map_linux.go b/pkg/bpf/map_linux.go index de000a732b8..c99a2ea3a9d 100644 --- a/pkg/bpf/map_linux.go +++ b/pkg/bpf/map_linux.go @@ -158,14 +158,17 @@ func OpenMap(name string) (*Map, error) { info, err := GetMapInfo(os.Getpid(), fd) if err != nil { + unix.Close(fd) return nil, err } if info.MapType == 0 { + unix.Close(fd) return nil, fmt.Errorf("Unable to determine map type") } if info.KeySize == 0 { + unix.Close(fd) return nil, fmt.Errorf("Unable to determine map key size") }