Re: [PATCH] ALSA: dummy: Refresh the CD capture switch before use

From: Takashi Iwai

Date: Fri Oct 16 2026 - 07:52:40 EST


On Fri, 16 Oct 2026 04:01:10 +0200,
Cen Zhang wrote:
>
> The CD Capture Switch control must remain live while
> snd_dummy_iobox_put() updates its access flags and uses its ID for
> notification. snd_card_dummy_new_mixer() caches the control pointer, but
> snd_ctl_remove_id() can unlink and free it without updating that cache.
>
> This requires a kernel caller to remove the switch while the dummy card
> stays connected and External I/O Box remains writable. Userspace
> ELEM_REMOVE rejects this driver control because it lacks
> SNDRV_CTL_ELEM_ACCESS_USER.

So, the removal shouldn't happen, but...

> With I/O Box initially 1 and CD Volume still
> present, the following ordered sequence is possible:
>
> 1. snd_ctl_remove_id() takes controls_rwsem for write, finds and
> unlinks CD Capture Switch, sends removal notifications and calls
> snd_ctl_free_one(), then drops the semaphore and returns.

... how this happens at all? Unless 1 really happens, the rest are
fictional dreams.

The same for another dummy driver patch. Does it really happen at
all?


thanks,

Takashi