Received: by 10.213.65.68 with SMTP id h4csp1726725imn; Mon, 19 Mar 2018 11:33:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELu/g0LOvK5aJnKJJFtnkqPYBqPtt1IsvJpNbuTiiefIbcMBJ2pw4ca8pok1jgS2eioD6kK4 X-Received: by 10.98.9.5 with SMTP id e5mr11160354pfd.189.1521484400957; Mon, 19 Mar 2018 11:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521484400; cv=none; d=google.com; s=arc-20160816; b=mF0YK1g0tM0mpgjOIfVCzIC7YHxVQIg2bW0YZxVwX9TqaDMm+UcFkaSt62Vaso92+Y zgbPXv1xqpbLJlZZzxJOMrndXSxAPJDEojF09XwApOwqSHjh2EnuKc8V39shq1B+hhZ0 +coNrR3MBpRaqkewdfveb4G43XJA4n2JDhVJHw7ulptkBvEYp9F8e6hQi7396j4iN5SA 1AJ6jG3n2vZum6iaMZtCkWbthnrNNo1c9txbp0oOvwBEUwlNumQrOD3Euqkfi2FxC1wI 7s5MOdXRpqc9JfO51aCnpZSuzmFiPg57i8B/9ApOEeN7I0Uar5Ke2AMR2dp/WVr5BgJZ 96QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XE25kcUgPjZdtay+ma7u6ZC3m1C3XcryFxot5/UlRdY=; b=WGWD3cmhE3D8+4AE1TZJkfquL8OS41ReWfnGDRS+ucas3NnvhKf4knnzcl9K5MRKz/ lPaTnZieGjXMuL1/6VWORxxlD7/mgpwHhi7ELubge/FBL3iQbD5r94o6I/OsGcRtZvPw pezaIum6KFX0d1ZLZGeJsNFCSpVd0Hmwaqd1q02M2Dj8v7PwMqzDnHaPiPJQ2VPaEvVV ZPEne+tksbwiQGbcLFZWyD8XDBatMDCMf0DChCaCC6SNxjffUab77jhA2w2tVRZ/78S1 Flg4vmofuN3K+6qwVGtKfzSbRFTMCxW2f4OePrvAHaso0LfPrgvafP1nlZ9vqS07NMLa hxEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si432857plp.33.2018.03.19.11.33.06; Mon, 19 Mar 2018 11:33:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032121AbeCSSbb (ORCPT + 99 others); Mon, 19 Mar 2018 14:31:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53544 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032087AbeCSSbV (ORCPT ); Mon, 19 Mar 2018 14:31:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1FAB7103C; Mon, 19 Mar 2018 18:31:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.15 14/52] ALSA: seq: Clear client entry before deleting else at closing Date: Mon, 19 Mar 2018 19:08:12 +0100 Message-Id: <20180319180735.933761422@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180734.976730813@linuxfoundation.org> References: <20180319180734.976730813@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit a2ff19f7b70118ced291a28d5313469914de451b upstream. When releasing a client, we need to clear the clienttab[] entry at first, then call snd_seq_queue_client_leave(). Otherwise, the in-flight cell in the queue might be picked up by the timer interrupt via snd_seq_check_queue() before calling snd_seq_queue_client_leave(), and it's delivered to another queue while the client is clearing queues. This may eventually result in an uncleared cell remaining in a queue, and the later snd_seq_pool_delete() may need to wait for a long time until the event gets really processed. By moving the clienttab[] clearance at the beginning of release, any event delivery of a cell belonging to this client will fail at a later point, since snd_seq_client_ptr() returns NULL. Thus the cell that was picked up by the timer interrupt will be returned immediately without further delivery, and the long stall of snd_seq_delete_pool() can be avoided, too. Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/seq/seq_clientmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -255,12 +255,12 @@ static int seq_free_client1(struct snd_s if (!client) return 0; - snd_seq_delete_all_ports(client); - snd_seq_queue_client_leave(client->number); spin_lock_irqsave(&clients_lock, flags); clienttablock[client->number] = 1; clienttab[client->number] = NULL; spin_unlock_irqrestore(&clients_lock, flags); + snd_seq_delete_all_ports(client); + snd_seq_queue_client_leave(client->number); snd_use_lock_sync(&client->use_lock); snd_seq_queue_client_termination(client->number); if (client->pool)