From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B69AC432C3 for ; Fri, 22 Nov 2019 11:27:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67A092070E for ; Fri, 22 Nov 2019 11:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574422069; bh=ImmlDRzMG4QM7y293HzEHL2Nt8F3ObbdD/6TybDalBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PIcw/BeFFw1lFdgXt+cEAU7HrVp7INKv63y7saz5dMaeayf/H5k97yzTVMPi9YOOq OOv2DPw4YG2JkHF6fuqbili1hWXgMWN4EnyDC4wCW7LD/lBAIMOwcKj9pcZIEXTje3 zo8CEdHrY5z8/f5gKjtxjyj8CExcPqSnGUnEihZ8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727515AbfKVKb5 (ORCPT ); Fri, 22 Nov 2019 05:31:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:52724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfKVKb5 (ORCPT ); Fri, 22 Nov 2019 05:31:57 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4635920714; Fri, 22 Nov 2019 10:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574418716; bh=ImmlDRzMG4QM7y293HzEHL2Nt8F3ObbdD/6TybDalBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4/XEmRJ9jmfGIB14OIn4frqvyNVkXzQLbwRIXZlKb+DMheaHvObK9pGpERb7jc14 EKgfbGG027WYTtfUEsHQH17AFINm0iox3cIPUxsXJc10OZdmKe6ljcFI/zPIcfG47V ++2xEAEwtTZot7+u4bKXudXFRse9tmCPVZkOQ1O0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Henry Lin , Takashi Iwai Subject: [PATCH 4.4 004/159] ALSA: usb-audio: not submit urb for stopped endpoint Date: Fri, 22 Nov 2019 11:26:35 +0100 Message-Id: <20191122100708.764223290@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100704.194776704@linuxfoundation.org> References: <20191122100704.194776704@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Henry Lin commit 528699317dd6dc722dccc11b68800cf945109390 upstream. While output urb's snd_complete_urb() is executing, calling prepare_outbound_urb() may cause endpoint stopped before prepare_outbound_urb() returns and result in next urb submitted to stopped endpoint. usb-audio driver cannot re-use it afterwards as the urb is still hold by usb stack. This change checks EP_FLAG_RUNNING flag after prepare_outbound_urb() again to let snd_complete_urb() know the endpoint already stopped and does not submit next urb. Below kind of error will be fixed: [ 213.153103] usb 1-2: timeout: still 1 active urbs on EP #1 [ 213.164121] usb 1-2: cannot submit urb 0, error -16: unknown error Signed-off-by: Henry Lin Cc: Link: https://lore.kernel.org/r/20191113021420.13377-1-henryl@nvidia.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/endpoint.c | 3 +++ 1 file changed, 3 insertions(+) --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -403,6 +403,9 @@ static void snd_complete_urb(struct urb } prepare_outbound_urb(ep, ctx); + /* can be stopped during prepare callback */ + if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) + goto exit_clear; } else { retire_inbound_urb(ep, ctx); /* can be stopped during retire callback */