From: Mathieu Desnoyers Date: Fri, 24 Jun 2011 04:45:07 +0000 (-0400) Subject: check for IS_ERR for perf return value X-Git-Tag: v2.0-pre1~32 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0478c519c5d71914799a3047749283fbfc18a95f;p=lttng-modules.git check for IS_ERR for perf return value Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-context-perf-counters.c b/lttng-context-perf-counters.c index c6f73037..5327e6ef 100644 --- a/lttng-context-perf-counters.c +++ b/lttng-context-perf-counters.c @@ -36,7 +36,7 @@ void perf_counter_record(struct lttng_ctx_field *field, uint64_t value; event = field->u.perf_counter.e[ctx->cpu]; - if (likely(event) && likely(event->pmu)) { + if (likely(event)) { event->pmu->read(event); value = local64_read(&event->count); } else { @@ -111,7 +111,7 @@ int __cpuinit lttng_perf_counter_cpu_hp_callback(struct notifier_block *nb, case CPU_ONLINE_FROZEN: pevent = perf_event_create_kernel_counter(attr, cpu, NULL, overflow_callback); - if (!pevent) + if (!pevent || IS_ERR(pevent)) return NOTIFY_BAD; barrier(); /* Create perf counter before setting event */ events[cpu] = pevent; @@ -182,7 +182,7 @@ int lttng_add_perf_counter_to_ctx(uint32_t type, for_each_online_cpu(cpu) { events[cpu] = perf_event_create_kernel_counter(attr, cpu, NULL, overflow_callback); - if (!events[cpu]) { + if (!events[cpu] || IS_ERR(events[cpu])) { ret = -EINVAL; goto counter_error; } @@ -210,7 +210,7 @@ int lttng_add_perf_counter_to_ctx(uint32_t type, counter_error: for_each_online_cpu(cpu) { - if (events[cpu]) + if (events[cpu] && !IS_ERR(events[cpu])) perf_event_release_kernel(events[cpu]); } put_online_cpus();