diff options
author | David Ahern <dsahern@gmail.com> | 2013-05-25 18:24:46 -0600 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-08-08 14:35:35 +0900 |
commit | 9be512ebe9ab6f060eacce7d627d762633c64755 (patch) | |
tree | 3d81035c016b5c51363c45b3c477da5d3002bad2 /tools | |
parent | d2a73c26d4e2db8569f90db4ca3d735c9f51b084 (diff) | |
download | linux-3.10-9be512ebe9ab6f060eacce7d627d762633c64755.tar.gz linux-3.10-9be512ebe9ab6f060eacce7d627d762633c64755.tar.bz2 linux-3.10-9be512ebe9ab6f060eacce7d627d762633c64755.zip |
perf kvm: Handle realloc failures
Save previous pointer and free on failure.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1369527896-3650-7-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-kvm.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 533501e2b07..24b78aecc92 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -328,6 +328,7 @@ static int kvm_events_hash_fn(u64 key) static bool kvm_event_expand(struct kvm_event *event, int vcpu_id) { int old_max_vcpu = event->max_vcpu; + void *prev; if (vcpu_id < event->max_vcpu) return true; @@ -335,9 +336,11 @@ static bool kvm_event_expand(struct kvm_event *event, int vcpu_id) while (event->max_vcpu <= vcpu_id) event->max_vcpu += DEFAULT_VCPU_NUM; + prev = event->vcpu; event->vcpu = realloc(event->vcpu, event->max_vcpu * sizeof(*event->vcpu)); if (!event->vcpu) { + free(prev); pr_err("Not enough memory\n"); return false; } |