summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAdrián Larumbe <adrian.larumbe@collabora.com>2023-08-08 22:03:30 +0100
committerKamil Konieczny <kamil.konieczny@linux.intel.com>2023-08-11 15:45:49 +0200
commitef91e1fc0a6dfabaab469161dd9ad51469647d2e (patch)
tree679ff078efc76da61e31163d713edbc0e7c1643d /tools
parent0c69e942098d201108cce061b35e3ac6d7b50483 (diff)
gputop: fix region array max iteration index loop bug
If c->regions->num_regions equals 1, then c->regions->max_region_id equals 0, so neither of the cumulative memory region size loops will be executed. Fix it by adjusting loop termination condition. Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/gputop.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/gputop.c b/tools/gputop.c
index ac106abea..ea95e0333 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -166,11 +166,11 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
len = printf("%*s ", c->clients->max_pid_len, c->pid_str);
if (c->regions->num_regions) {
- for (sz = 0, i = 0; i < c->regions->max_region_id; i++)
+ for (sz = 0, i = 0; i <= c->regions->max_region_id; i++)
sz += c->memory[i].total;
len += print_size(sz);
- for (sz = 0, i = 0; i < c->regions->max_region_id; i++)
+ for (sz = 0, i = 0; i <= c->regions->max_region_id; i++)
sz += c->memory[i].resident;
len += print_size(sz);
}