Skip to content

Commit ac957e8

Browse files
committed
ALSA: pcm: oss: Place the plugin buffer overflow checks correctly (for 5.7)
[ This is again a forward-port of the fix applied for 5.6-base code (commit 4285de0) to 5.7-base, hence neither Fixes nor Cc-to-stable tags are included here -- tiwai ] The checks of the plugin buffer overflow in the previous fix by commit f2ecf90 ("ALSA: pcm: oss: Avoid plugin buffer overflow") are put in the wrong places mistakenly, which leads to the expected (repeated) sound when the rate plugin is involved. Fix in the right places. Also, at those right places, the zero check is needed for the termination node, so added there as well, and let's get it done, finally. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 977dfef commit ac957e8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sound/core/oss/pcm_plugin.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ static snd_pcm_sframes_t calc_dst_frames(struct snd_pcm_substream *plug,
205205
plugin = snd_pcm_plug_first(plug);
206206
while (plugin && frames > 0) {
207207
plugin_next = plugin->next;
208+
if (check_size && plugin->buf_frames &&
209+
frames > plugin->buf_frames)
210+
frames = plugin->buf_frames;
208211
if (plugin->dst_frames) {
209212
frames = plugin->dst_frames(plugin, frames);
210213
if (frames < 0)
211214
return frames;
212215
}
213-
if (check_size && frames > plugin->buf_frames)
214-
frames = plugin->buf_frames;
215216
plugin = plugin_next;
216217
}
217218
return frames;
@@ -225,14 +226,15 @@ static snd_pcm_sframes_t calc_src_frames(struct snd_pcm_substream *plug,
225226

226227
plugin = snd_pcm_plug_last(plug);
227228
while (plugin && frames > 0) {
228-
if (check_size && frames > plugin->buf_frames)
229-
frames = plugin->buf_frames;
230229
plugin_prev = plugin->prev;
231230
if (plugin->src_frames) {
232231
frames = plugin->src_frames(plugin, frames);
233232
if (frames < 0)
234233
return frames;
235234
}
235+
if (check_size && plugin->buf_frames &&
236+
frames > plugin->buf_frames)
237+
frames = plugin->buf_frames;
236238
plugin = plugin_prev;
237239
}
238240
return frames;

0 commit comments

Comments
 (0)