diff options
-rw-r--r-- | kernel/perf_counter.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index c6c38fb7766a..f7a8ab9576e4 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -2968,8 +2968,10 @@ static void perf_counter_comm_event(struct perf_comm_event *comm_event) | |||
2968 | struct perf_cpu_context *cpuctx; | 2968 | struct perf_cpu_context *cpuctx; |
2969 | struct perf_counter_context *ctx; | 2969 | struct perf_counter_context *ctx; |
2970 | unsigned int size; | 2970 | unsigned int size; |
2971 | char *comm = comm_event->task->comm; | 2971 | char comm[TASK_COMM_LEN]; |
2972 | 2972 | ||
2973 | memset(comm, 0, sizeof(comm)); | ||
2974 | strncpy(comm, comm_event->task->comm, sizeof(comm)); | ||
2973 | size = ALIGN(strlen(comm)+1, sizeof(u64)); | 2975 | size = ALIGN(strlen(comm)+1, sizeof(u64)); |
2974 | 2976 | ||
2975 | comm_event->comm = comm; | 2977 | comm_event->comm = comm; |
@@ -3088,8 +3090,15 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event) | |||
3088 | char *buf = NULL; | 3090 | char *buf = NULL; |
3089 | const char *name; | 3091 | const char *name; |
3090 | 3092 | ||
3093 | memset(tmp, 0, sizeof(tmp)); | ||
3094 | |||
3091 | if (file) { | 3095 | if (file) { |
3092 | buf = kzalloc(PATH_MAX, GFP_KERNEL); | 3096 | /* |
3097 | * d_path works from the end of the buffer backwards, so we | ||
3098 | * need to add enough zero bytes after the string to handle | ||
3099 | * the 64bit alignment we do later. | ||
3100 | */ | ||
3101 | buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL); | ||
3093 | if (!buf) { | 3102 | if (!buf) { |
3094 | name = strncpy(tmp, "//enomem", sizeof(tmp)); | 3103 | name = strncpy(tmp, "//enomem", sizeof(tmp)); |
3095 | goto got_name; | 3104 | goto got_name; |
@@ -3100,9 +3109,11 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event) | |||
3100 | goto got_name; | 3109 | goto got_name; |
3101 | } | 3110 | } |
3102 | } else { | 3111 | } else { |
3103 | name = arch_vma_name(mmap_event->vma); | 3112 | if (arch_vma_name(mmap_event->vma)) { |
3104 | if (name) | 3113 | name = strncpy(tmp, arch_vma_name(mmap_event->vma), |
3114 | sizeof(tmp)); | ||
3105 | goto got_name; | 3115 | goto got_name; |
3116 | } | ||
3106 | 3117 | ||
3107 | if (!vma->vm_mm) { | 3118 | if (!vma->vm_mm) { |
3108 | name = strncpy(tmp, "[vdso]", sizeof(tmp)); | 3119 | name = strncpy(tmp, "[vdso]", sizeof(tmp)); |