Skip to content

Commit e14ebde

Browse files
committed
ALSA: pcm: Fix error checks of default read/write copy ops
copy_from/to_iter() returns the actually copied bytes, and the more correct check should be to compare with the given bytes, instead of zero-check. Fixes: cf393ba ("ALSA: pcm: Add copy ops with iov_iter") Reported-by: Al Viro <viro@zeniv.linux.org.uk> Closes: https://lore.kernel.org/r/20230902053044.GJ3390869@ZenIV Link: https://lore.kernel.org/r/20230902061044.19366-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent ef98a48 commit e14ebde

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sound/core/pcm_lib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,8 +1992,8 @@ static int default_write_copy(struct snd_pcm_substream *substream,
19921992
int channel, unsigned long hwoff,
19931993
struct iov_iter *iter, unsigned long bytes)
19941994
{
1995-
if (!copy_from_iter(get_dma_ptr(substream->runtime, channel, hwoff),
1996-
bytes, iter))
1995+
if (copy_from_iter(get_dma_ptr(substream->runtime, channel, hwoff),
1996+
bytes, iter) != bytes)
19971997
return -EFAULT;
19981998
return 0;
19991999
}
@@ -2025,8 +2025,8 @@ static int default_read_copy(struct snd_pcm_substream *substream,
20252025
int channel, unsigned long hwoff,
20262026
struct iov_iter *iter, unsigned long bytes)
20272027
{
2028-
if (!copy_to_iter(get_dma_ptr(substream->runtime, channel, hwoff),
2029-
bytes, iter))
2028+
if (copy_to_iter(get_dma_ptr(substream->runtime, channel, hwoff),
2029+
bytes, iter) != bytes)
20302030
return -EFAULT;
20312031
return 0;
20322032
}

0 commit comments

Comments
 (0)