From: Mathieu Desnoyers Date: Wed, 30 Apr 2014 16:09:59 +0000 (+0200) Subject: Fix: perf ust: check close return value X-Git-Tag: v2.5.0-rc1~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6c2125aff1c8d8217072931ee6223be80112dcb2;p=lttng-ust.git Fix: perf ust: check close return value Fix coverity defect: ** CID 1208905: Unchecked return value (CHECKED_RETURN) /liblttng-ust/lttng-context-perf-counters.c: 147 in setup_perf() Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-context-perf-counters.c b/liblttng-ust/lttng-context-perf-counters.c index d6bd41cc..99691c06 100644 --- a/liblttng-ust/lttng-context-perf-counters.c +++ b/liblttng-ust/lttng-context-perf-counters.c @@ -134,7 +134,7 @@ static struct perf_event_mmap_page *setup_perf(struct perf_event_attr *attr) { void *perf_addr; - int fd; + int fd, ret; fd = sys_perf_event_open(attr, 0, -1, -1, 0); if (fd < 0) @@ -144,7 +144,10 @@ struct perf_event_mmap_page *setup_perf(struct perf_event_attr *attr) PROT_READ, MAP_SHARED, fd, 0); if (perf_addr == MAP_FAILED) return NULL; - close(fd); + ret = close(fd); + if (ret) { + perror("Error closing LTTng-UST perf memory mapping FD"); + } return perf_addr; }