From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:51381 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752963AbbEDMiI (ORCPT ); Mon, 4 May 2015 08:38:08 -0400 From: Jiri Slaby To: stable@vger.kernel.org Cc: Ezequiel Garcia , Hans Verkuil , Mauro Carvalho Chehab , Jiri Slaby Subject: [patch added to the 3.12 stable tree] stk1160: Make sure current buffer is released Date: Mon, 4 May 2015 14:37:46 +0200 Message-Id: <1430743082-6957-55-git-send-email-jslaby@suse.cz> In-Reply-To: <1430743082-6957-1-git-send-email-jslaby@suse.cz> References: <1430743082-6957-1-git-send-email-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Ezequiel Garcia This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit aeff09276748b66072f2db2e668cec955cf41959 upstream. The available (i.e. not used) buffers are returned by stk1160_clear_queue(), on the stop_streaming() path. However, this is insufficient and the current buffer must be released as well. Fix it. Signed-off-by: Ezequiel Garcia Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jiri Slaby --- drivers/media/usb/stk1160/stk1160-v4l.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c index c45c9881bb5f..4572530346fb 100644 --- a/drivers/media/usb/stk1160/stk1160-v4l.c +++ b/drivers/media/usb/stk1160/stk1160-v4l.c @@ -244,6 +244,11 @@ static int stk1160_stop_streaming(struct stk1160 *dev) if (mutex_lock_interruptible(&dev->v4l_lock)) return -ERESTARTSYS; + /* + * Once URBs are cancelled, the URB complete handler + * won't be running. This is required to safely release the + * current buffer (dev->isoc_ctl.buf). + */ stk1160_cancel_isoc(dev); /* @@ -624,8 +629,16 @@ void stk1160_clear_queue(struct stk1160 *dev) stk1160_info("buffer [%p/%d] aborted\n", buf, buf->vb.v4l2_buf.index); } - /* It's important to clear current buffer */ - dev->isoc_ctl.buf = NULL; + + /* It's important to release the current buffer */ + if (dev->isoc_ctl.buf) { + buf = dev->isoc_ctl.buf; + dev->isoc_ctl.buf = NULL; + + vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); + stk1160_info("buffer [%p/%d] aborted\n", + buf, buf->vb.v4l2_buf.index); + } spin_unlock_irqrestore(&dev->buf_lock, flags); } -- 2.3.5