Received: by 10.213.65.68 with SMTP id h4csp36402imn; Mon, 19 Mar 2018 18:43:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELu6UVOhEuaGyTEl/bQRqcAyR6vwV277lVKrIUD/F/5F+XaoWBv0U2oEvf/S0sytbm1O9k1L X-Received: by 2002:a17:902:42e:: with SMTP id 43-v6mr14384218ple.186.1521510219758; Mon, 19 Mar 2018 18:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510219; cv=none; d=google.com; s=arc-20160816; b=EoTO7CkzxTz5O/bh81v8qMxtRy+xQxWsQa31HQ2wA2hsnNdCEsWpvyFzEPJJPKsWaW 74Q3RLAo4JV6sJOLvrNfpx7maAtXWESNXXfV+Crrr1JQ9EzNbbtrereZgfV7mj7Kf4M5 UGDjP2EF8RmF69xj6d+Ytgw18cFj3mniqvZAzNJC4bbFGiajhiQrgXQDDhpc4X3XGdgE EgF1+mDTf6EyuOj3zGs12LK8l2YtibBUAbK18ax3i2UZ5UX+yMlE/f5p/2POO+L3qOuz 70l8DSuEj/RSuO2UXH/uaSe33rDhfMGnR2a3ICYNdMOFFIcNyEl+g5iIFUEbrYN2whXI 5JQw== 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=3V7aeG/qVk1ViPaXlsE0fOO9XPKX2ZZmbXlYY1qumzw=; b=RxWfyNeN7hoZlCv2nl7zQoKaW0C1gAgnfzQoBTGkZLOILz+MFdOEop2lGxIjFYAD/b gPuXOgQHvStwBdGXsgLIVx3K72HF3hnfmCwPnc/Pss8DAS21j8PkNzPOCXS9vAc3uRJY OHMh2WkHu5a+L029kIpAJrdD11s9iOqhy4jJTI79/EQW2Wht0p4wQOfXijETxO6OMj6k JCWaPKSmIPc7haSmessg5zHe6saEi9BW8p/BQCWg0wdg/u0j3UuMsVyRUzbB9aSAGV+4 vs79fyRLjen2iSqcTQwLiYcwzV5mCejIBqyw09x0HGtmvsrywduGFjcdgeK+7NWY4JqY AyLw== 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 a4-v6si561302plm.660.2018.03.19.18.43.25; Mon, 19 Mar 2018 18:43:39 -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 S970100AbeCSS2L (ORCPT + 99 others); Mon, 19 Mar 2018 14:28:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51472 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965748AbeCSS2A (ORCPT ); Mon, 19 Mar 2018 14:28:00 -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 97ABF1281; Mon, 19 Mar 2018 18:27:59 +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.9 225/241] ALSA: seq: Clear client entry before deleting else at closing Date: Mon, 19 Mar 2018 19:08:10 +0100 Message-Id: <20180319180800.488107639@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-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)