From patchwork Tue Apr 24 20:59:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 10361083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C4717602D6 for ; Tue, 24 Apr 2018 21:00:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B505728AB7 for ; Tue, 24 Apr 2018 21:00:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9A0728B3F; Tue, 24 Apr 2018 21:00:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F24428AB7 for ; Tue, 24 Apr 2018 21:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751271AbeDXVAS (ORCPT ); Tue, 24 Apr 2018 17:00:18 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:47380 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751216AbeDXVAR (ORCPT ); Tue, 24 Apr 2018 17:00:17 -0400 Received: from garnet.hsd1.pa.comcast.net (unknown [IPv6:2601:547:500:4c18:3f80:d6cb:283e:9a0]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F2C565172; Tue, 24 Apr 2018 23:00:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1524603616; bh=995cYstn6M53vhheGnu/pJOyT4EK8p1SjxuLCIajCOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=rRT/aC+v65HC9PF4CubnIvrSf0mDfTEMG9jveqo8J+2sDKDy7wTWPhAy6lk2hePmW Xz2kH0nkdqn8gy73tUktLovoJ0gOxMe4RKp191FpA0exKFFDBApA011qOXqxRZbPDb Z+qypgGm5qu7vHOWzayeUlFnuLcWbebdGq41GrkE= From: Paul Elder To: linux-usb@vger.kernel.org Cc: Paul Elder , laurent.pinchart@ideasonboard.com, balbi@kernel.org, gregkh@linuxfoundation.org, rogerq@ti.com Subject: [PATCH v2 3/3] usb: gadget: uvc: disable stream when disconnected Date: Tue, 24 Apr 2018 16:59:36 -0400 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Down the call stack from the ioctl handler for VIDIOC_STREAMON, uvc_video_alloc_requests contains a BUG_ON, which in the high level, triggers when VIDIOC_STREAMON ioctl is issued without VIDIOC_STREAMOFF being issued previously. This can also be triggered by starting the stream and then physically disconnecting usb. To fix this, do the streamoff procedures on usb disconnect. Signed-off-by: Paul Elder --- Changes in v2: Nothing drivers/usb/gadget/function/f_uvc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index fa34dcbe1197..5bb79888e3f7 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -374,9 +374,12 @@ uvc_function_disable(struct usb_function *f) { struct uvc_device *uvc = to_uvc(f); struct v4l2_event v4l2_event; + struct uvc_video *video = &uvc->video; INFO(f->config->cdev, "uvc_function_disable\n"); + uvcg_video_enable(video, 0); + memset(&v4l2_event, 0, sizeof(v4l2_event)); v4l2_event.type = UVC_EVENT_DISCONNECT; v4l2_event_queue(&uvc->vdev, &v4l2_event);