Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794049261; b=znBA+qTUSAUm+Kp+h4OexNK1iPFJXoTkU9O+tnQhifQ97XAULADvZg/jjBpTMwbwTDmA lzpxl7ETZlLhPFS81DtsoG6shuZLtWJ80isKEsjGOS6LvWGJtgoKy3IsHGuVItZ0lqgXe bnJ3f6KFvbCb2gRJp2sxP6Jp08BgJhlSHKWqcPfeNENrAjkjiBzFRzt4FCM2oxXHWt5Rt u6GDI2HJ8gIXUHBUy7ssRJWix4y7Q/jUh9BCgedhFPC1ZXT3hIwYSSre0ZFcdudN89A9n d4SkkP3R/X+yNXmqY4LO5V33jp+zF3PKl4SrCKGM31v/F6028ly9QURD4f4l/g4vepQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794049261; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=xrjddU1KYU2NfCgrwo9CSDirf46h460i+BM+0hJxZp8=; b=KVKDP8CKHSchXXAgYhgFw9SI5d8iXv26B0PM8cO/9gV6Wcxu8nrZfUlmGSBioNQ38E95 WhXDUr8P+aDeLK4h8VTif5mgZQwty5w6FnnwJlbiWiFayQuA75VpIDzrHJYPD5vz9C1f4 rD9dRZKF8E10hqqARxZQKleUQmgtpE1pJg9C5N2WXwfcNwM0XTYo2Wzu67RsvCPjTBsf6 N1bgzF/DnFHNACWv79uBg+vfhrAlu9d3XcjW6YLrUKif7FOwhCk84nYrcYCG+aNGuxUZ8 XNK4jaqZBTbq8oWcUFKd2cMwUAlvy4vkWVMvskF/VQhhhRRtqkwqmh6FQjkXlTHw6DQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VJfc4pCv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 210A0606A32F for ; Sat, 7 Nov 2026 11:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VJfc4pCv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 926641F0089F; Sat, 7 Nov 2026 11:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794049261; bh=xrjddU1KYU2NfCgrwo9CSDirf46h460i+BM+0hJxZp8=; h=From:To:Cc:Subject:Date; b=VJfc4pCvT2/toYENDDHHfHbVClIBgSV1q75ajmTyFRKO8hTvcDNZYm8Yr6nVnknW9 jbeCMvyEUo35APdLCbUNvtU+SBO9j41694x8VK7vrjvlkzneGzlbzPZ4eu7LlQDDqS 4GeCLy+GC9nOaQT3gJNcd0qzQ/hHYTt1ohO472es7lsbE9t+P7pTxpRzNZddSbeAUk RD/0OKcLh0BVEJchTQpM+J24USqzBGPXGNrmfgtiuZdtqLLGGlnG7ZJmxdow8Szu2U oensY6gFropr9dePr4SRPHiAdhmrtJGvWVEYeHMMM3yeo+vFqOs/z28hvhfOFhmw6m oke2wh/7ZbywQ== From: Sasha Levin To: runyu.xiao@seu.edu.cn, tiwai@suse.de Cc: stable@vger.kernel.org Subject: FAILED: patch "[PATCH] ALSA: usb-audio: Protect Roland control activation" failed to apply to 5.15-stable tree Date: Sat, 7 Nov 2026 06:00:59 -0500 Message-ID: <20261107060059-failed-5.15-19b42c1fff7f@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 19b42c1fff7f220a6346c614d79ce1bda6d95b40 # git commit -s git send-email --to '' --in-reply-to '20261107060059-failed-5.15-19b42c1fff7f@kernel.org' --subject-prefix 'PATCH 5.15.y' 'HEAD^..' Thanks, Sasha ------------------ original commit in Linus's tree ------------------ From 19b42c1fff7f220a6346c614d79ce1bda6d95b40 Mon Sep 17 00:00:00 2001 From: Runyu Xiao Date: Tue, 29 Sep 2026 22:17:26 +0800 Subject: [PATCH] ALSA: usb-audio: Protect Roland control activation The USB MIDI driver changes the Roland MIDI Input Mode control's access flags directly from the rawmidi open and close paths. These changes are not protected by the ALSA control core and the corresponding notifications can race with control access. Use snd_ctl_activate_id() so that the control core updates the access flags and sends the notification under its lock. Release the USB MIDI mutex before calling it because the control write path holds controls_rwsem while roland_load_put() takes the USB MIDI mutex. Keep the state transition and alternate-setting change under the USB MIDI mutex; rawmidi's open mutex serializes the enclosing open and close paths. Fixes: 96f61d9ade82 ("sound: usb-audio: allow switching altsetting on Roland USB MIDI devices") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Runyu Xiao Link: https://patch.msgid.link/20260929141726.2166899-1-runyu.xiao@seu.edu.cn Signed-off-by: Takashi Iwai --- sound/usb/midi.c | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 0480a9b89e8f3..e3d1575540613 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -1150,41 +1150,42 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, int open) { struct snd_usb_midi *umidi = substream->rmidi->private_data; - struct snd_kcontrol *ctl; + struct snd_ctl_elem_id ctl_id; + bool activate_ctl = false; + bool active; guard(rwsem_read)(&umidi->disc_rwsem); if (umidi->disconnected) return open ? -ENODEV : 0; - guard(mutex)(&umidi->mutex); - if (open) { - if (!umidi->opened[0] && !umidi->opened[1]) { - if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0].access |= - SNDRV_CTL_ELEM_ACCESS_INACTIVE; - snd_ctl_notify(umidi->card, - SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); - update_roland_altsetting(umidi); + scoped_guard(mutex, &umidi->mutex) { + if (open) { + if (!umidi->opened[0] && !umidi->opened[1]) { + if (umidi->roland_load_ctl) { + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = false; + update_roland_altsetting(umidi); + } } - } - umidi->opened[dir]++; - if (umidi->opened[1]) - snd_usbmidi_input_start(&umidi->list); - } else { - umidi->opened[dir]--; - if (!umidi->opened[1] && !umidi->keep_input_running) - snd_usbmidi_input_stop(&umidi->list); - if (!umidi->opened[0] && !umidi->opened[1]) { - if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0].access &= - ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; - snd_ctl_notify(umidi->card, - SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); + umidi->opened[dir]++; + if (umidi->opened[1]) + snd_usbmidi_input_start(&umidi->list); + } else { + umidi->opened[dir]--; + if (!umidi->opened[1] && !umidi->keep_input_running) + snd_usbmidi_input_stop(&umidi->list); + if (!umidi->opened[0] && !umidi->opened[1]) { + if (umidi->roland_load_ctl) { + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = true; + } } } } + if (activate_ctl) + snd_ctl_activate_id(umidi->card, &ctl_id, active); return 0; } -- 2.53.0