Mesa (master): i965: Check calloc return value in gather_statistics_results()
Ville Syrjala
vsyrjala at kemper.freedesktop.org
Thu Jun 26 12:47:13 UTC 2014
Module: Mesa
Branch: master
Commit: 375943bc0a99bec6e4d07b07acd0e9004b2a9ea0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=375943bc0a99bec6e4d07b07acd0e9004b2a9ea0
Author: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Date: Thu May 8 16:19:51 2014 +0300
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 <juhapekka.heikkila at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/drivers/dri/i965/brw_performance_monitor.c | 15 ++++++++++++++-
1 file changed, 14 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 3f64eae..74b6ac9 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;
More information about the mesa-commit
mailing list