Received: by 10.213.65.68 with SMTP id h4csp36440imn; Mon, 19 Mar 2018 18:43:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELsL/fCpZcyUvCvmw6Nefs7lE2y5fTi8SgideYVCM7cEv3tWv8OoteMGtPNUkZQw5Bhe/bse X-Received: by 2002:a17:902:b704:: with SMTP id d4-v6mr14763978pls.406.1521510224591; Mon, 19 Mar 2018 18:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510224; cv=none; d=google.com; s=arc-20160816; b=wiaZ4g+Y+fq0cwOAJIdxwdXqt7w4AYDEtvIc//RJA1DNU5mci2x60pj9NyJHhBS1oL 5qZUWDel+xqHgEfpPeoKPhxZ/v7OC266FMo+1Z1uwQXJTwfjwpGlogrhlnAMOwKNW2WU s1jl0MRJK92AgG4GpOO6Bj2SbaDPb0Snop9I1KNtYJG9eBlR42dpEa8VVN0MgAkx8v8j t/eHAIVocPK/4RqzNT1cy5Gf4xPwCvDQMI6ZnCCpf7sEyHuldzWK6WS5/2YvpppYIVJh l1P34r/lUlXhfQaySeHhESA1Ky/eSc99fbw8/kamA0PnIhuqW2ZIX3sQ1FXR+mpQ/R7G RHjw== 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=FIJueuJT62GnrPQVgh7dR3jn59muFWljcR5k3/WCy1k=; b=DK5kQbOmsF3aDODXKR/OkhqWjaBh46vUyy3fTn5Vn6fCci9/BoSEicGehmeiZUAjrz DDn0ahZznZNsdy12KchC9TBneUOnFS3FgDwWuN3KJ0+G8I88paCf3bTbJpMFsf4IE0UN 56AaMcUnB63/pqKIPkqXwFDuI3Te3RC4XoMQMi+o7W0M7rdSYsl2qvCbgLYz+0EnTzS9 ahbTBpQ9FrrWzShiYEjQGL0A1GOpmHa66U197c/iD0WlA1uTXWlGwP9JBwK5MXLUf5mR kJTnoZJ097WQ7M/AmgEHKCAF0YzVikmkMuRSFyCwB+vpXKRIS6GYCXJf4jGBcaRdojzw rfjA== 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 61-v6si491853plr.136.2018.03.19.18.43.31; Mon, 19 Mar 2018 18:43:44 -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 S969092AbeCSSRI (ORCPT + 99 others); Mon, 19 Mar 2018 14:17:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45400 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968940AbeCSSRD (ORCPT ); Mon, 19 Mar 2018 14:17:03 -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 723691242; Mon, 19 Mar 2018 18:17:02 +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.4 119/134] ALSA: seq: Clear client entry before deleting else at closing Date: Mon, 19 Mar 2018 19:06:42 +0100 Message-Id: <20180319171906.442618866@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@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.4-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 @@ -270,12 +270,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)