genirq/timings: Prevent potential array overflow in __irq_timings_store()
authorBen Dai <ben.dai@unisoc.com>
Sun, 25 Apr 2021 15:09:03 +0000 (23:09 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 10 Aug 2021 13:39:00 +0000 (15:39 +0200)
commitb9cc7d8a4656a6e815852c27ab50365009cb69c1
treeeedd846b978aa1c7783fdd1c5e281715c558044f
parentff363f480e5997051dd1de949121ffda3b753741
genirq/timings: Prevent potential array overflow in __irq_timings_store()

When the interrupt interval is greater than 2 ^ PREDICTION_BUFFER_SIZE *
PREDICTION_FACTOR us and less than 1s, the calculated index will be greater
than the length of irqs->ema_time[]. Check the calculated index before
using it to prevent array overflow.

Fixes: 23aa3b9a6b7d ("genirq/timings: Encapsulate storing function")
Signed-off-by: Ben Dai <ben.dai@unisoc.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210425150903.25456-1-ben.dai9703@gmail.com
kernel/irq/timings.c