* FAILED: patch "[PATCH] ALSA: scarlett2: Allow flash writes ending at segment" failed to apply to 6.12-stable tree
@ 2026-05-28 7:48 gregkh
2026-05-29 17:24 ` [PATCH 6.12.y 1/2] ALSA: scarlett2: Return ENOSPC for out-of-bounds flash writes Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-05-28 7:48 UTC (permalink / raw)
To: cassiogabrielcontato, tiwai; +Cc: stable
The patch below does not apply to the 6.12-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 <stable@vger.kernel.org>.
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-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x a69b677e47a80319ce148d61cc29a2b57006e78d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026052816-limelight-debtor-c8aa@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a69b677e47a80319ce148d61cc29a2b57006e78d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A1ssio=20Gabriel?= <cassiogabrielcontato@gmail.com>
Date: Tue, 19 May 2026 11:46:19 -0300
Subject: [PATCH] ALSA: scarlett2: Allow flash writes ending at segment
boundary
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
scarlett2_hwdep_write() rejects writes when offset + count is greater than
or equal to the selected flash segment size. That incorrectly treats a
write ending exactly at the end of the segment as out of space, although
the last byte written is still within the segment.
Split invalid argument checks from the segment-space check, keep
zero-length writes as no-ops, and compare count against the remaining
segment size. This permits exact-end writes and avoids relying on
offset + count before deciding whether the request is in bounds.
Fixes: 1abfbd3c9527 ("ALSA: scarlett2: Add support for uploading new firmware")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260519-alsa-scarlett2-flash-write-boundary-v1-1-b550480e92da@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index 0f83f8981213..8e80a7165faf 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -9187,12 +9187,15 @@ static long scarlett2_hwdep_write(struct snd_hwdep *hw,
flash_size = private->flash_segment_blocks[segment_id] *
SCARLETT2_FLASH_BLOCK_SIZE;
- if (count < 0 || *offset < 0 || *offset + count >= flash_size)
- return -ENOSPC;
+ if (count < 0 || *offset < 0)
+ return -EINVAL;
if (!count)
return 0;
+ if (*offset >= flash_size || count > flash_size - *offset)
+ return -ENOSPC;
+
/* Limit the *req size to SCARLETT2_FLASH_RW_MAX */
if (count > max_data_size)
count = max_data_size;
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.12.y 1/2] ALSA: scarlett2: Return ENOSPC for out-of-bounds flash writes
2026-05-28 7:48 FAILED: patch "[PATCH] ALSA: scarlett2: Allow flash writes ending at segment" failed to apply to 6.12-stable tree gregkh
@ 2026-05-29 17:24 ` Sasha Levin
2026-05-29 17:25 ` [PATCH 6.12.y 2/2] ALSA: scarlett2: Allow flash writes ending at segment boundary Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-05-29 17:24 UTC (permalink / raw)
To: stable; +Cc: Geoffrey D. Bennett, Takashi Iwai, Sasha Levin
From: "Geoffrey D. Bennett" <g@b4.vu>
[ Upstream commit 74641bfcbf4e698b770b1b62a74e73934843e90e ]
When writing to flash, return ENOSPC instead of EINVAL if the requested
write would exceed the size of the flash segment.
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/3a4af07b0329bed5ffb6994594e4f7bd202aad0f.1727971672.git.g@b4.vu
Stable-dep-of: a69b677e47a8 ("ALSA: scarlett2: Allow flash writes ending at segment boundary")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/usb/mixer_scarlett2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index ef5945aa40e4a..564a9b04a443a 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -9523,7 +9523,7 @@ static long scarlett2_hwdep_write(struct snd_hwdep *hw,
SCARLETT2_FLASH_BLOCK_SIZE;
if (count < 0 || *offset < 0 || *offset + count >= flash_size)
- return -EINVAL;
+ return -ENOSPC;
if (!count)
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.12.y 2/2] ALSA: scarlett2: Allow flash writes ending at segment boundary
2026-05-29 17:24 ` [PATCH 6.12.y 1/2] ALSA: scarlett2: Return ENOSPC for out-of-bounds flash writes Sasha Levin
@ 2026-05-29 17:25 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-05-29 17:25 UTC (permalink / raw)
To: stable; +Cc: Cássio Gabriel, Takashi Iwai, Sasha Levin
From: Cássio Gabriel <cassiogabrielcontato@gmail.com>
[ Upstream commit a69b677e47a80319ce148d61cc29a2b57006e78d ]
scarlett2_hwdep_write() rejects writes when offset + count is greater than
or equal to the selected flash segment size. That incorrectly treats a
write ending exactly at the end of the segment as out of space, although
the last byte written is still within the segment.
Split invalid argument checks from the segment-space check, keep
zero-length writes as no-ops, and compare count against the remaining
segment size. This permits exact-end writes and avoids relying on
offset + count before deciding whether the request is in bounds.
Fixes: 1abfbd3c9527 ("ALSA: scarlett2: Add support for uploading new firmware")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260519-alsa-scarlett2-flash-write-boundary-v1-1-b550480e92da@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/usb/mixer_scarlett2.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c
index 564a9b04a443a..568bb0d4ebbd1 100644
--- a/sound/usb/mixer_scarlett2.c
+++ b/sound/usb/mixer_scarlett2.c
@@ -9522,12 +9522,15 @@ static long scarlett2_hwdep_write(struct snd_hwdep *hw,
flash_size = private->flash_segment_blocks[segment_id] *
SCARLETT2_FLASH_BLOCK_SIZE;
- if (count < 0 || *offset < 0 || *offset + count >= flash_size)
- return -ENOSPC;
+ if (count < 0 || *offset < 0)
+ return -EINVAL;
if (!count)
return 0;
+ if (*offset >= flash_size || count > flash_size - *offset)
+ return -ENOSPC;
+
/* Limit the *req size to SCARLETT2_FLASH_RW_MAX */
if (count > max_data_size)
count = max_data_size;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-29 17:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28 7:48 FAILED: patch "[PATCH] ALSA: scarlett2: Allow flash writes ending at segment" failed to apply to 6.12-stable tree gregkh
2026-05-29 17:24 ` [PATCH 6.12.y 1/2] ALSA: scarlett2: Return ENOSPC for out-of-bounds flash writes Sasha Levin
2026-05-29 17:25 ` [PATCH 6.12.y 2/2] ALSA: scarlett2: Allow flash writes ending at segment boundary Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox