ALSA: seq: Don't lose partial read failure

snd_seq_read() returns an error even if one or more events have been
successfully read before the error (except for -EAGAIN case), but this
rather doesn't follow the POSIX standard that wants the processed
bytes.  Change the behavior to return the processed bytes when it's
positive, instead.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261007172533.14667-8-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2026-10-07 19:25:25 +02:00
parent 344e74ac50
commit 7e1f297fce

View File

@ -480,11 +480,11 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count,
if (err < 0) {
if (cell)
snd_seq_fifo_cell_putback(fifo, cell);
if (err == -EAGAIN && result > 0)
err = 0;
}
return (err < 0) ? err : result;
if (result > 0)
return result;
return err < 0 ? err : 0;
}