Skip to content

Commit 34a1e87

Browse files
olsajirikkourt
authored andcommitted
tetragon: Do proper error path cleanup in uprobeAttachExtra
We need to unpin the program in case the attach function fails. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
1 parent 0bd5b8f commit 34a1e87

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/sensors/program/loader_linux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,11 @@ func uprobeAttachExtra(load *Program, bpfDir string,
439439
return nil, fmt.Errorf("pinning '%s' to '%s' failed: %w", load.Label, pinPath, err)
440440
}
441441

442-
return attach(load, prog, spec, bpfDir, pin)
442+
un, err := attach(load, prog, spec, bpfDir, pin)
443+
if err != nil {
444+
prog.Unpin()
445+
}
446+
return un, err
443447
}
444448

445449
func uprobeAttach(load *Program, bpfDir string,

0 commit comments

Comments
 (0)