ALSA: pcm: Fix error checks of default read/write copy ops
PATCH 1/2 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 cf393babb37a ("ALSA: pcm: Add copy ops with iov_iter")
Reported-by Al Viro <[email protected]>
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/pcm_lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/core/pcm_lib.c +4 -4
@@ -1992,8 +1992,8 @@ static int default_write_copy(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, struct iov_iter *iter, unsigned long bytes) { - if (!copy_from_iter(get_dma_ptr(substream->runtime, channel, hwoff), - bytes, iter)) + if (copy_from_iter(get_dma_ptr(substream->runtime, channel, hwoff), + bytes, iter) != bytes) return -EFAULT;return 0 ; }
@@ -2025,8 +2025,8 @@ static int default_read_copy(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, struct iov_iter *iter, unsigned long bytes) { - if (!copy_to_iter(get_dma_ptr(substream->runtime, channel, hwoff), - bytes, iter)) + if (copy_to_iter(get_dma_ptr(substream->runtime, channel, hwoff), + bytes, iter) != bytes) return -EFAULT;return 0 ; }
Signature · 1 line
2.35.3
PATCH 2/2 ALSA: sb: Fix wrong argument in commented code
While rewriting the code from sockptr_t to iov_iter during the development, I forgot to replace one place in emu8000-pcm code. As it's in the disabled area (with ifdef), it's never built and overlooked. Replace with the proper argument NULL.
Fixes 9d0fdc602de9 ("ALSA: emu8000: Convert to generic PCM copy ops")
Reported-by Al Viro <[email protected]>
Signed-off-by Takashi Iwai <[email protected]>
--- sound/isa/sb/emu8000_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/isa/sb/emu8000_pcm.c +1 -1
@@ -456,7 +456,7 @@ static int emu8k_pcm_silence(struct snd_pcm_substream *subs,/* convert to word unit */ pos = (pos <<1 ) + rec->loop_start[voice]; count <<=1 ; -LOOP_WRITE (rec, pos,USER_SOCKPTR (NULL ), count); +LOOP_WRITE (rec, pos,NULL , count);return 0 ; }
Signature · 1 line
2.35.3