exynos: Fix out-of-bounds access in exynos4210_gcomp_find
PATCH 1/1 exynos: Fix out-of-bounds access in exynos4210_gcomp_find
When 'res' equals -1, the array 's->g_timer.reg.comp[]' is accessed out of bounds.
--- hw/timer/exynos4210_mct.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/timer/exynos4210_mct.c +8 -5
@@ -480,11 +480,14 @@ static int32_t exynos4210_gcomp_find(Exynos4210MCTState *s) res = min_comp_i; } -DPRINTF ("found comparator %d: comp 0x%llx distance 0x%llx, gfrc 0x%llx\n" , - res, - s->g_timer.reg.comp[res], - distance_min, - gfrc); +if (res >=0 ) { +DPRINTF ("found comparator %d: " +"comp 0x%llx distance 0x%llx, gfrc 0x%llx\n" , + res, + s->g_timer.reg.comp[res], + distance_min, + gfrc); + }return res; }
Signature · 1 line
2.39.2
Peter Maydell
AppliedQuoted 8 lines · Feng Jiang
When 'res' equals -1, the array 's->g_timer.reg.comp[]' is accessed out of bounds.
Signed-off-by Feng Jiang <[email protected]>--- hw/timer/exynos4210_mct.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Only happens if you change the source code to enable the debug printfs though, which isn't the default. I'll tweak the commit message to make that clearer.
Applied to target-arm.next for 8.1, thanks.
-- PMM
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Feng Jiang
When 'res' equals -1, the array 's->g_timer.reg.comp[]' is accessed out of bounds.
Signed-off-by Feng Jiang <[email protected]>--- hw/timer/exynos4210_mct.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Quoted 8 lines
Only happens if you change the source code to enable the debug printfs though, which isn't the default. I'll tweak the commit message to make that clearer.
Applied to target-arm.next for 8.1, thanks.
-- PMM
Hi Peter, Thanks very much for your review!
Next time I will write the commit message more clearly and in detail.
Best regards,
Feng