1 From aeff09276748b66072f2db2e668cec955cf41959 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
3 Date: Tue, 10 Mar 2015 11:37:14 -0300
4 Subject: [media] stk1160: Make sure current buffer is released
6 From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
8 commit aeff09276748b66072f2db2e668cec955cf41959 upstream.
10 The available (i.e. not used) buffers are returned by stk1160_clear_queue(),
11 on the stop_streaming() path. However, this is insufficient and the current
12 buffer must be released as well. Fix it.
14 Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
15 Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
16 Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 drivers/media/usb/stk1160/stk1160-v4l.c | 17 +++++++++++++++--
21 1 file changed, 15 insertions(+), 2 deletions(-)
23 --- a/drivers/media/usb/stk1160/stk1160-v4l.c
24 +++ b/drivers/media/usb/stk1160/stk1160-v4l.c
25 @@ -244,6 +244,11 @@ static int stk1160_stop_streaming(struct
26 if (mutex_lock_interruptible(&dev->v4l_lock))
30 + * Once URBs are cancelled, the URB complete handler
31 + * won't be running. This is required to safely release the
32 + * current buffer (dev->isoc_ctl.buf).
34 stk1160_cancel_isoc(dev);
37 @@ -624,8 +629,16 @@ void stk1160_clear_queue(struct stk1160
38 stk1160_info("buffer [%p/%d] aborted\n",
39 buf, buf->vb.v4l2_buf.index);
41 - /* It's important to clear current buffer */
42 - dev->isoc_ctl.buf = NULL;
44 + /* It's important to release the current buffer */
45 + if (dev->isoc_ctl.buf) {
46 + buf = dev->isoc_ctl.buf;
47 + dev->isoc_ctl.buf = NULL;
49 + vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
50 + stk1160_info("buffer [%p/%d] aborted\n",
51 + buf, buf->vb.v4l2_buf.index);
53 spin_unlock_irqrestore(&dev->buf_lock, flags);