Skip to content

Commit

Permalink
pkg/sensors: checks for nil pointer dereference
Browse files Browse the repository at this point in the history
Signed-off-by: Mahe Tardy <[email protected]>
  • Loading branch information
mtardy committed Jun 14, 2024
1 parent 6d462c0 commit 1b4c684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sensors/tracing/generickprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ func addKprobe(funcName string, f *v1alpha1.KProbeSpec, in *addKprobeIn) (id idt
return idtable.UninitializedEntryID, err
}

if f == nil {
return errFn(errors.New("error adding kprobe, the kprobe spec is nil"))
}

config := &api.EventConfig{}
config.PolicyID = uint32(in.policyID)
if len(f.ReturnArgAction) > 0 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/sensors/tracing/generictracepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func createGenericTracepoint(
policyName string,
customHandler eventhandler.Handler,
) (*genericTracepoint, error) {
if conf == nil {
return nil, errors.New("failed creating generic tracepoint, conf is nil")
}

tp := tracepoint.Tracepoint{
Subsys: conf.Subsystem,
Event: conf.Event,
Expand Down

0 comments on commit 1b4c684

Please sign in to comment.