Fix: perf ust: check close return value
[lttng-ust.git] / liblttng-ust / lttng-context-perf-counters.c
index d6bd41cc9e20a170dc73f5d76d473781cdd1e737..99691c067f23a421ceee6f5f07f883b68b543e03 100644 (file)
@@ -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;
 }
 
This page took 0.026454 seconds and 4 git commands to generate.