From c2529908a1905cd8b76bed0a6039975226cb24eb Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Tue, 31 Mar 2015 06:43:28 -0300 Subject: [PATCH] [media] sur40: fix occasional hard freeze due to buffer queue underrun This patch fixes a kernel panic which occurs when buf_list is empty. This can happen occasionally when user space is under heavy load (e.g. due to image processing on the CPU) and new buffers aren't re-queued fast enough. In that case, vb2_start_streaming_called can return true, but when the spinlock is taken and sur40_poll attempts to fetch the next buffer from buf_list, the list is in fact empty. This patch needs to be applied on top of the queued one adding V4L2 support to the sur40 driver. Signed-off-by: Florian Echtler Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/input/touchscreen/sur40.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index b295e1744ea1..a24eba5ea843 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -380,6 +380,11 @@ static void sur40_process_video(struct sur40_state *sur40) /* get a new buffer from the list */ spin_lock(&sur40->qlock); + if (list_empty(&sur40->buf_list)) { + dev_dbg(sur40->dev, "buffer queue empty\n"); + spin_unlock(&sur40->qlock); + return; + } new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list); list_del(&new_buf->list); spin_unlock(&sur40->qlock); -- 2.34.1