From 19b7ad347f16ff958ed3214f0a2fc3f5ad96e286 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Tue, 8 Dec 2020 16:49:43 +0800 Subject: [PATCH] input: qcom-hv-haptics: fix out of bound of FIFO samples array When calculating play length for FIFO play, it is out of bound of the FIFO samples array. Fix it. Change-Id: I8ad458802a0070f493ac53160ab90a6cf648d9e7 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 28fa714075ba..c6294c374a41 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -675,7 +675,7 @@ static int get_fifo_play_length_us(struct fifo_cfg *fifo, u32 t_lra_us) if (!fifo) return -EINVAL; - for (i = fifo->num_s; i > 0; i--) + for (i = fifo->num_s - 1; i > 0; i--) if (fifo->samples[i] != 0) break;