Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3305790rwa; Tue, 23 Aug 2022 02:24:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cvx3k1fX57gdAVYoWN71qMmIrhiJCysC310s8Zxgj7Qz4X5e+foTLjEQAmrmf+uDcderm X-Received: by 2002:a63:e241:0:b0:41b:b374:caf8 with SMTP id y1-20020a63e241000000b0041bb374caf8mr20576142pgj.310.1661246689713; Tue, 23 Aug 2022 02:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661246689; cv=none; d=google.com; s=arc-20160816; b=pRgzD5bH02P8jTL3CKL1flqfgLEvabUCdsW3PTmLSgW9SqtMzPkTa9iVV0bDQihEZI yK4zuYVWuzX4RFJQC5sOwZNpqX/zuzuevuSAv6e0gyAR7JaHLSsM2S9/p4j02qjiwIFg zE3ndOSlpEaEOW/xvWYTVv9s5XMd/tDWs/y7jcDdcsLYICdRbd2xNyxUdjVyaO5G6hh0 ycb9x8UTjKfOLrcGOo9FKiOfbxxXO3tW5RgEOKpiR/Yn812/BcDJH0wxec9ESDSu87uW i397FnoHccNIRLs0aZD+VSOYgK+z4yzs0fLBXaAmTngs6kkUWpksybRX58sIYXzTcP8O bn2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ubvrGUmeVIlng5Pp7nxLTe+Pg/M+dL2EAjferSz/WR8=; b=jJFaU7Qf4O12ZElAHQ9w8r5u2dgjb7xs+DyR6EZCj8ke50yDAwJsEdxXw+ThhLZSwa AC2n7BnisyYlnr9LGUMhMJfIMawhLkgeduxZHqXJMUET214mFbhv46cFmf1eaD+ICRQB oWFX99o60hN0mA2WtMCRlzjBwwPhG+mhnJIB0lzXqCAFxHH8b0TwIBM8BxGbRlSF7MH4 PXEYNjgGajVNIA0Cj0G6AcBI7jxMcC7l7FLqGKLAnleE2lGeL80Jxo483ScbpUtDvJLD KoE2dopUmAOGd48l8K+pa4h/1YEN5tmlnWjrFISzOCY8YOkt0QVCvBFZkf+9AVzqhT0x uH+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v6Q6TFrj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a170902e80c00b0016c049ada3csi1856617plg.454.2022.08.23.02.24.38; Tue, 23 Aug 2022 02:24:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v6Q6TFrj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349401AbiHWJX4 (ORCPT + 99 others); Tue, 23 Aug 2022 05:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350382AbiHWJVo (ORCPT ); Tue, 23 Aug 2022 05:21:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7161C8C447; Tue, 23 Aug 2022 01:34:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62292614E7; Tue, 23 Aug 2022 08:34:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693F8C433C1; Tue, 23 Aug 2022 08:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243681; bh=X/ZLYxxDnih0e0paGcYJ4tSJ7KVpOyF0ATP2RLTK/q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v6Q6TFrjHMPXMshqefjPLyV50Qj/doAKlFhsBcw+/Rz3OVDzw6P4YUfEoG6h499cy rDRozcjLSZGPmP8Iz71KXrCpuMjQGrCi0BsetXhqfnLYX5yHVYMKcSe0SVEUHX91oo 8Ovhb35YouvM7hD9vYI0n2hUbvtfOHV55RSpEl94= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sasha Levin Subject: [PATCH 5.19 354/365] ALSA: control: Use deferred fasync helper Date: Tue, 23 Aug 2022 10:04:15 +0200 Message-Id: <20220823080133.088929037@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit 4a971e84a7ae10a38d875cd2d4e487c8d1682ca3 ] For avoiding the potential deadlock via kill_fasync() call, use the new fasync helpers to defer the invocation from the control API. Note that it's merely a workaround. Another note: although we haven't received reports about the deadlock with the control API, the deadlock is still potentially possible, and it's better to align the behavior with other core APIs (PCM and timer); so let's move altogether. Link: https://lore.kernel.org/r/20220728125945.29533-5-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- include/sound/control.h | 2 +- sound/core/control.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/sound/control.h b/include/sound/control.h index 985c51a8fb74..a1fc7e0a47d9 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -109,7 +109,7 @@ struct snd_ctl_file { int preferred_subdevice[SND_CTL_SUBDEV_ITEMS]; wait_queue_head_t change_sleep; spinlock_t read_lock; - struct fasync_struct *fasync; + struct snd_fasync *fasync; int subscribed; /* read interface is activated */ struct list_head events; /* waiting events for read */ }; diff --git a/sound/core/control.c b/sound/core/control.c index a25c0d64d104..f66fe4be30d3 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -127,6 +127,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file) if (control->vd[idx].owner == ctl) control->vd[idx].owner = NULL; up_write(&card->controls_rwsem); + snd_fasync_free(ctl->fasync); snd_ctl_empty_read_queue(ctl); put_pid(ctl->pid); kfree(ctl); @@ -181,7 +182,7 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask, _found: wake_up(&ctl->change_sleep); spin_unlock(&ctl->read_lock); - kill_fasync(&ctl->fasync, SIGIO, POLL_IN); + snd_kill_fasync(ctl->fasync, SIGIO, POLL_IN); } read_unlock_irqrestore(&card->ctl_files_rwlock, flags); } @@ -2002,7 +2003,7 @@ static int snd_ctl_fasync(int fd, struct file * file, int on) struct snd_ctl_file *ctl; ctl = file->private_data; - return fasync_helper(fd, file, on, &ctl->fasync); + return snd_fasync_helper(fd, file, on, &ctl->fasync); } /* return the preferred subdevice number if already assigned; @@ -2170,7 +2171,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device) read_lock_irqsave(&card->ctl_files_rwlock, flags); list_for_each_entry(ctl, &card->ctl_files, list) { wake_up(&ctl->change_sleep); - kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); + snd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR); } read_unlock_irqrestore(&card->ctl_files_rwlock, flags); -- 2.35.1