From patchwork Tue Mar 10 14:37:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 5978131 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8C25C9F318 for ; Tue, 10 Mar 2015 14:40:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DBCA201FA for ; Tue, 10 Mar 2015 14:40:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16A2F2021F for ; Tue, 10 Mar 2015 14:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753562AbbCJOkC (ORCPT ); Tue, 10 Mar 2015 10:40:02 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:40755 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbbCJOkA (ORCPT ); Tue, 10 Mar 2015 10:40:00 -0400 Received: by wivr20 with SMTP id r20so30769359wiv.5 for ; Tue, 10 Mar 2015 07:39:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TvZyXbW6L+/bw4rnTL4nz+A1qe+AloK1BTOmiVGZCgI=; b=FlebgBdL5D/ZYIIrIMR6qIUQsQWcOGgUCMo6A866WhMYXPmHawNOkKM/8IOgfGjIxJ 9XFSpbfQRCxcSQ7ArZgxIHnH4qpNPJlAjSpUC21KJVIon8/rl7tbV6xxYyNT8yuDhLK3 L+C9c1fAJRU3DfdOpEV+1kiWLkAgedI8T5q4JHK0HdAIoI9xhHRRDvMCHfuDnf0eYfzX 5Q7h5EMvbKZRtbSzDKZf1qDZUIG649ChTR+pxhnCxC0k1xkYSjf6zZez0mDC6L+EgiWU WT52/FkH7DeqhoISnajqDCNoQMa7dqAORVpFDelXOlFXuPSrEOJ9MttShxme9F61WEwJ oNsA== X-Gm-Message-State: ALoCoQldX7zKC9YS8vC/4iR4p1trIRzyEMkk1TFxLn0btIWOOZNJPVFQ+xIccKqVXuSm/x8GcdWL X-Received: by 10.194.201.164 with SMTP id kb4mr68275718wjc.32.1425998399499; Tue, 10 Mar 2015 07:39:59 -0700 (PDT) Received: from laptop.hh.imgtec.org ([190.2.108.156]) by mx.google.com with ESMTPSA id ew5sm20554695wic.14.2015.03.10.07.39.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Mar 2015 07:39:58 -0700 (PDT) From: Ezequiel Garcia To: Hans Verkuil Cc: , Ezequiel Garcia , stable@vger.kernel.org Subject: [PATCH] stk1160: Make sure current buffer is released Date: Tue, 10 Mar 2015 11:37:14 -0300 Message-Id: <1425998234-2692-1-git-send-email-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.3.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: stable@vger.kernel.org Signed-off-by: Ezequiel Garcia --- 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 2330543..f6d0334 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); }