Skip to contentSkip to conversation

ALSA: pcm: Don't setup bogus iov_iter for silencing

PATCH New Takashi Iwai 1 participant 1 message May 17 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Don't setup bogus iov_iter for silencing

At transition to the iov_iter for PCM data transfer, we blindly applied the iov_iter setup also for silencing (i.e. data = NULL), and it leads to a calculation of bogus iov_iter. Fortunately this didn't cause troubles on most of architectures but it goes wrong on RISC-V now, causing a NULL dereference.

Handle the NULL data case to treat the silencing in interleaved_copy() for addressing the bug above. noninterleaved_copy() has already the NULL data handling, so it doesn't need changes.

Fixes cf393babb37a ("ALSA: pcm: Add copy ops with iov_iter")
---
 sound/core/pcm_lib.c | 3 +++
 1 file changed, 3 insertions(+)
sound/core/pcm_lib.c +3 -0
index 09c421cd9319..fe597f7d522d 100644
@@ -2138,6 +2138,9 @@ static int interleaved_copy(struct snd_pcm_substream *substream,
 	off = frames_to_bytes(runtime, off);
 	frames = frames_to_bytes(runtime, frames);
 
+	if (!data)
+		return fill_silence(substream, 0, hwoff, NULL, frames);
+
 	return do_transfer(substream, 0, hwoff, data + off, frames, transfer,
 			   in_kernel);
 }
Signature · 1 line
2.54.0