public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>, Sasha Levin <sashal@kernel.org>,
	perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org
Subject: [PATCH AUTOSEL 5.18 32/39] ALSA: control: Use deferred fasync helper
Date: Sun, 14 Aug 2022 12:23:21 -0400	[thread overview]
Message-ID: <20220814162332.2396012-32-sashal@kernel.org> (raw)
In-Reply-To: <20220814162332.2396012-1-sashal@kernel.org>

From: Takashi Iwai <tiwai@suse.de>

[ 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 <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


  parent reply	other threads:[~2022-08-14 16:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-14 16:22 [PATCH AUTOSEL 5.18 01/39] lib/list_debug.c: Detect uninitialized lists Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 02/39] tty: serial: Fix refcount leak bug in ucc_uart.c Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 03/39] KVM: PPC: Book3S HV: Fix "rm_exit" entry in debugfs timings Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 04/39] vfio: Clear the caps->buf to NULL after free Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 05/39] mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 06/39] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 07/39] riscv: dts: microchip: Add mpfs' topology information Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 08/39] ALSA: hda: Fix page fault in snd_hda_codec_shutdown() Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 09/39] modules: Ensure natural alignment for .altinstructions and __bug_table sections Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 10/39] ASoC: rsnd: care default case on rsnd_ssiu_busif_err_irq_ctrl() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 11/39] riscv: dts: sifive: Add fu540 topology information Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 12/39] riscv: dts: sifive: Add fu740 " Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 13/39] riscv: dts: canaan: Add k210 " Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 14/39] riscv: mmap with PROT_WRITE but no PROT_READ is invalid Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 15/39] RISC-V: Add fast call path of crash_kexec() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 16/39] ALSA: hda/realtek: Enable speaker and mute LEDs for HP laptops Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 17/39] ASoC: SOF: Intel: hda: add sanity check on SSP index reported by NHLT Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 18/39] ASoC: Intel: sof_es8336: Fix GPIO quirks set via module option Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 19/39] ASoC: Intel: sof_es8336: ignore GpioInt when looking for speaker/headset GPIO lines Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 20/39] ASoC: Intel: sof_nau8825: Move quirk check to the front in late probe Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 21/39] watchdog: export lockup_detector_reconfigure Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 22/39] powerpc/watchdog: introduce a NMI watchdog's factor Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 23/39] powerpc/pseries/mobility: set NMI watchdog factor during an LPM Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 24/39] powerpc/32: Set an IBAT covering up to _einittext during init Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 25/39] powerpc/32: Don't always pass -mcpu=powerpc to the compiler Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 26/39] ASoC: codecs: va-macro: use fsgen as clock Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 27/39] ovl: warn if trusted xattr creation fails Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 28/39] powerpc/ioda/iommu/debugfs: Generate unique debugfs entries Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 29/39] ALSA: core: Add async signal helpers Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 30/39] ALSA: timer: Use deferred fasync helper Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 31/39] ALSA: pcm: " Sasha Levin
2022-08-14 16:23 ` Sasha Levin [this message]
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 33/39] f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 34/39] f2fs: fix to do sanity check on segment type in build_sit_entries() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 35/39] smb3: check xattr value length earlier Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 36/39] powerpc/64: Init jump labels before parse_early_param() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 37/39] venus: pm_helpers: Fix warning in OPP during probe Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 38/39] video: fbdev: i740fb: Check the argument of i740_calc_vclk() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 39/39] MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0 Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220814162332.2396012-32-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox