aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorJuha-Pekka Heikkila <[email protected]>2014-05-08 16:19:51 +0300
committerVille Syrjälä <[email protected]>2014-06-26 15:37:14 +0300
commit375943bc0a99bec6e4d07b07acd0e9004b2a9ea0 (patch)
tree9d2b81b97b72f24a346787ba18a2e2a4c1c1d24c /src/mesa/drivers
parent9a8acafa47558cafeb37f80f4b30061ac1962c69 (diff)
i965: Check calloc return value in gather_statistics_results()
Check calloc return value and report on error, also later skip results handling if there was no memory to store results to. Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_performance_monitor.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
index 3f64eae57eb..74b6ac91cc8 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
@@ -610,6 +610,10 @@ gather_statistics_results(struct brw_context *brw,
ctx->PerfMonitor.Groups[PIPELINE_STATS_COUNTERS].NumCounters;
monitor->pipeline_stats_results = calloc(num_counters, sizeof(uint64_t));
+ if (monitor->pipeline_stats_results == NULL) {
+ _mesa_error_no_memory(__func__);
+ return;
+ }
drm_intel_bo_map(monitor->pipeline_stats_bo, false);
uint64_t *start = monitor->pipeline_stats_bo->virtual;
@@ -1318,9 +1322,18 @@ brw_get_perf_monitor_result(struct gl_context *ctx,
const int num_counters =
ctx->PerfMonitor.Groups[PIPELINE_STATS_COUNTERS].NumCounters;
- if (!monitor->pipeline_stats_results)
+ if (!monitor->pipeline_stats_results) {
gather_statistics_results(brw, monitor);
+ /* Check if we did really get the results */
+ if (!monitor->pipeline_stats_results) {
+ if (bytes_written) {
+ *bytes_written = 0;
+ }
+ return;
+ }
+ }
+
for (int i = 0; i < num_counters; i++) {
if (BITSET_TEST(m->ActiveCounters[PIPELINE_STATS_COUNTERS], i)) {
data[offset++] = PIPELINE_STATS_COUNTERS;