@@ -768,6 +768,7 @@ int main(int argc, char **argv)
768
768
};
769
769
struct syms_cache * syms_cache = NULL ;
770
770
struct ksyms * ksyms = NULL ;
771
+ struct perf_buffer * pb = NULL ;
771
772
struct bpf_link * cpu_links [MAX_CPU_NR ] = {};
772
773
struct bpf_link * uprobe_links [UPROBE_SIZE ] = {};
773
774
struct profile_bpf * obj ;
@@ -860,8 +861,8 @@ int main(int argc, char **argv)
860
861
lua_bt_map = init_lua_stack_map ();
861
862
if (!lua_bt_map )
862
863
goto cleanup ;
863
- struct perf_buffer * pb = perf_buffer__new (bpf_map__fd (obj -> maps .lua_event_output ), PERF_BUFFER_PAGES ,
864
- handle_lua_stack_event , handle_lua_stack_lost_events , NULL , NULL );
864
+ pb = perf_buffer__new (bpf_map__fd (obj -> maps .lua_event_output ), PERF_BUFFER_PAGES ,
865
+ handle_lua_stack_event , handle_lua_stack_lost_events , NULL , NULL );
865
866
if (!pb )
866
867
{
867
868
err = - errno ;
@@ -931,8 +932,11 @@ int main(int argc, char **argv)
931
932
for (i = 0 ; i < UPROBE_SIZE ; i ++ )
932
933
bpf_link__destroy (uprobe_links [i ]);
933
934
profile_bpf__destroy (obj );
934
- perf_buffer__free (pb );
935
- syms_cache__free (syms_cache );
936
- ksyms__free (ksyms );
935
+ if (pb )
936
+ perf_buffer__free (pb );
937
+ if (syms_cache )
938
+ syms_cache__free (syms_cache );
939
+ if (ksyms )
940
+ ksyms__free (ksyms );
937
941
return err != 0 ;
938
942
}
0 commit comments