[Mesa-dev] [PATCH 17/20] i965: Check calloc return value in gather_statistics_results()
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Wed May 14 10:56:03 PDT 2014
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 <juhapekka.heikkila at gmail.com>
---
src/mesa/drivers/dri/i965/brw_performance_monitor.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
index ff3cb97..da85cce 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;
@@ -1321,7 +1325,8 @@ brw_get_perf_monitor_result(struct gl_context *ctx,
if (!monitor->pipeline_stats_results)
gather_statistics_results(brw, monitor);
- for (int i = 0; i < num_counters; i++) {
+ for (int i = 0; i < num_counters
+ && monitor->pipeline_stats_results != NULL; i++) {
if (BITSET_TEST(m->ActiveCounters[PIPELINE_STATS_COUNTERS], i)) {
data[offset++] = PIPELINE_STATS_COUNTERS;
data[offset++] = i;
--
1.8.1.2
More information about the mesa-dev
mailing list