Skip to content

Commit 359b626

Browse files
CassivsGabriellistiwai
authored andcommitted
ALSA: pcmtest: Return -EFAULT on pattern read copy failure
pattern_write() reports -EFAULT when copy_from_user() fails, but pattern_read() converts copy_to_user() failures into a zero-length read. That makes a userspace buffer fault look like EOF instead of reporting the actual error. Return -EFAULT from pattern_read() when copying the pattern data to userspace fails, and update the file offset only after a successful copy. Fixes: 315a3d5 ("ALSA: Implement the new Virtual PCM Test Driver") Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Link: https://patch.msgid.link/20260501-alsa-pcmtest-pattern-read-efault-v1-1-53e1e8c11dda@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent ad39a18 commit 359b626

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

sound/drivers/pcmtest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,9 @@ static ssize_t pattern_read(struct file *file, char __user *u_buff, size_t len,
679679
return 0;
680680

681681
if (copy_to_user(u_buff, patt_buf->buf + *off, to_read))
682-
to_read = 0;
683-
else
684-
*off += to_read;
682+
return -EFAULT;
683+
684+
*off += to_read;
685685

686686
return to_read;
687687
}

0 commit comments

Comments
 (0)