Commit 359b626d authored by Cássio Gabriel's avatar Cássio Gabriel Committed by Takashi Iwai
Browse files

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: 315a3d57 ("ALSA: Implement the new Virtual PCM Test Driver")
Signed-off-by: default avatarCássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260501-alsa-pcmtest-pattern-read-efault-v1-1-53e1e8c11dda@gmail.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ad39a189
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -679,8 +679,8 @@ static ssize_t pattern_read(struct file *file, char __user *u_buff, size_t len,
		return 0;

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

	*off += to_read;

	return to_read;