8
8
#define pr_fmt (fmt ) "trace_uprobe: " fmt
9
9
10
10
#include <linux/bpf-cgroup.h>
11
+ #include <linux/cleanup.h>
11
12
#include <linux/ctype.h>
12
13
#include <linux/filter.h>
13
14
#include <linux/module.h>
19
20
#include <linux/uaccess.h>
20
21
#include <linux/uprobes.h>
21
22
23
+ #include "trace.h"
22
24
#include "trace_dynevent.h"
23
25
#include "trace_probe.h"
24
26
#include "trace_probe_tmpl.h"
@@ -537,15 +539,15 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
537
539
*/
538
540
static int __trace_uprobe_create (int argc , const char * * argv )
539
541
{
540
- struct trace_uprobe * tu ;
541
542
const char * event = NULL , * group = UPROBE_EVENT_SYSTEM ;
542
543
char * arg , * filename , * rctr , * rctr_end , * tmp ;
543
- char buf [MAX_EVENT_NAME_LEN ];
544
- char gbuf [MAX_EVENT_NAME_LEN ];
545
- enum probe_print_type ptype ;
546
- struct path path ;
547
544
unsigned long offset , ref_ctr_offset ;
545
+ char * gbuf __free (kfree ) = NULL ;
546
+ char * buf __free (kfree ) = NULL ;
547
+ enum probe_print_type ptype ;
548
+ struct trace_uprobe * tu ;
548
549
bool is_return = false;
550
+ struct path path ;
549
551
int i , ret ;
550
552
551
553
ref_ctr_offset = 0 ;
@@ -653,6 +655,10 @@ static int __trace_uprobe_create(int argc, const char **argv)
653
655
/* setup a probe */
654
656
trace_probe_log_set_index (0 );
655
657
if (event ) {
658
+ gbuf = kmalloc (MAX_EVENT_NAME_LEN , GFP_KERNEL );
659
+ if (!gbuf )
660
+ goto fail_mem ;
661
+
656
662
ret = traceprobe_parse_event_name (& event , & group , gbuf ,
657
663
event - argv [0 ]);
658
664
if (ret )
@@ -664,15 +670,16 @@ static int __trace_uprobe_create(int argc, const char **argv)
664
670
char * ptr ;
665
671
666
672
tail = kstrdup (kbasename (filename ), GFP_KERNEL );
667
- if (!tail ) {
668
- ret = - ENOMEM ;
669
- goto fail_address_parse ;
670
- }
673
+ if (!tail )
674
+ goto fail_mem ;
671
675
672
676
ptr = strpbrk (tail , ".-_" );
673
677
if (ptr )
674
678
* ptr = '\0' ;
675
679
680
+ buf = kmalloc (MAX_EVENT_NAME_LEN , GFP_KERNEL );
681
+ if (!buf )
682
+ goto fail_mem ;
676
683
snprintf (buf , MAX_EVENT_NAME_LEN , "%c_%s_0x%lx" , 'p' , tail , offset );
677
684
event = buf ;
678
685
kfree (tail );
@@ -724,6 +731,9 @@ static int __trace_uprobe_create(int argc, const char **argv)
724
731
trace_probe_log_clear ();
725
732
return ret ;
726
733
734
+ fail_mem :
735
+ ret = - ENOMEM ;
736
+
727
737
fail_address_parse :
728
738
trace_probe_log_clear ();
729
739
path_put (& path );
0 commit comments