Received: by 10.213.65.68 with SMTP id h4csp1740737imn; Mon, 19 Mar 2018 11:59:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELs20vYFT70eqmJhf3n2MJCtGl2HiUEiTTmuCk571OTxL27sfdMaaTdkXb+H7KOX8iIMNIb/ X-Received: by 2002:a17:902:f81:: with SMTP id 1-v6mr13472943plz.265.1521485986936; Mon, 19 Mar 2018 11:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521485986; cv=none; d=google.com; s=arc-20160816; b=OJN9/50CzxPAujMDCbxGU+cA25c0lZ67Pv4rf/juA4VkcLflI6L65VEK3je5HKKYVP w5SY/N+ueIFrBLbFj8kvTppfW8BdXS5zi7BvLmEAzLfP3qYnOh5HrE4FBtXrWEtAgDEz +ff5ttkBGezAApnBd00gk2tsD26mp8Cc0Epy0hyi1fDRJeemxYm3XEVlk08ihgB2Dgp6 WwYqCPqhWUmYNLAetijsrzGM20nxzz7bxT16lT1zN3E3gvEW4qovKx1tpD+Zm0Wa+zcM 21PZJkgd/KjWMRLIHkiuP1ArN27X/55z34KYEe0Ns7ysvz6zxFMY1gIIgEMBjjf2tbUe BXJg== 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=bQjvyVBNsDalgYldI7VM3aQaAhVsJFHpYzZxY3cI6og=; b=QoTqFSORrU4hIek7hRJOnryUU4uSgrNQ8tzaIE24VLYrutNLIku6OEm709HvHKpzgV uhOzTAsG5FAnb+BiyqbKmuC4qJdnwPlR2bUaINiNudBDqphS5ffNsc4YS7kf4nOp07bQ KPY8IV7mEqpdm5f+kHNcrqqA24VV3wP0NhjUEn8zPVhSUfdStvL5QUTYFrVz8J/LV3ki 07EMbpqO9unUYg71+plZViTBCS77hAU95bMJ1cPBkE99ZVAoh0ReNTe6P5+5SEetlQud n5Krh4TlVoz2N2S8LSqPk8x7jXV0jMaWr2mLFSmCjPQ1/Ie3p72Hel1CiABYbmcVwlcy gu4A== 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 j10-v6si518047plk.655.2018.03.19.11.59.32; Mon, 19 Mar 2018 11:59:46 -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 S1031869AbeCSS3n (ORCPT + 99 others); Mon, 19 Mar 2018 14:29:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52752 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934867AbeCSS3b (ORCPT ); Mon, 19 Mar 2018 14:29:31 -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 D6355111B; Mon, 19 Mar 2018 18:29:29 +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.14 16/41] ALSA: seq: Clear client entry before deleting else at closing Date: Mon, 19 Mar 2018 19:08:16 +0100 Message-Id: <20180319180733.289830425@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180732.195217948@linuxfoundation.org> References: <20180319180732.195217948@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.14-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)