mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 19:13:47 +02:00
ALSA: scarlett2: Allow flash writes ending at segment boundary
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: 1abfbd3c95 ("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>
This commit is contained in:
parent
12b1b4f565
commit
a69b677e47
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user