diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2018-05-17 09:10:25 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-05-24 10:49:05 -0400 |
commit | 794ddbd1a046ff5744209e615bdfcfd0f34c4c8d (patch) | |
tree | 3cf3c7e16550db85a5e59f206b20e804034d4576 /drivers/gpu | |
parent | c1b78dd65d6d3269c4b25d38fc57975acca02a1a (diff) |
gpu: nvgpu: fix oob access in submit profiling dump
The number of samples has to be at least the number of percentile ranges
(here 20) for the reporting to work as expected and also to not cause
negative indices in reading the sorted profile data. If there are not
enough samples, just report all zeroes.
Change-Id: Ie893859d95074f5ceabf6abe873941873668861d
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1721892
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/debug_fifo.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug_fifo.c b/drivers/gpu/nvgpu/common/linux/debug_fifo.c index b2a87e0d..f2aaef58 100644 --- a/drivers/gpu/nvgpu/common/linux/debug_fifo.c +++ b/drivers/gpu/nvgpu/common/linux/debug_fifo.c | |||
@@ -222,10 +222,11 @@ static unsigned int __gk20a_fifo_create_stats(struct gk20a *g, | |||
222 | __profile_cmp, NULL); | 222 | __profile_cmp, NULL); |
223 | 223 | ||
224 | /* build ranges */ | 224 | /* build ranges */ |
225 | for (index = 0; index < PERCENTILE_RANGES; index++) | 225 | for (index = 0; index < PERCENTILE_RANGES; index++) { |
226 | percentiles[index] = | 226 | percentiles[index] = nelem < PERCENTILE_RANGES ? 0 : |
227 | g->fifo.profile.sorted[(PERCENTILE_WIDTH * (index + 1) * | 227 | g->fifo.profile.sorted[(PERCENTILE_WIDTH * (index + 1) * |
228 | nelem)/100 - 1]; | 228 | nelem)/100 - 1]; |
229 | } | ||
229 | return nelem; | 230 | return nelem; |
230 | } | 231 | } |
231 | 232 | ||