From 30fb9b7766aaa480ec29bfbfcce411de851ae00b Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 13 Dec 2023 13:15:52 +0200 Subject: [PATCH] sound/alsa: fix missing StreamWithIdNotFound check stop() was not returning an error if stream_id was invalid, it was succeeding. Signed-off-by: Manos Pitsidianakis --- staging/vhost-device-sound/src/audio_backends/alsa.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/staging/vhost-device-sound/src/audio_backends/alsa.rs b/staging/vhost-device-sound/src/audio_backends/alsa.rs index 8e78d24..410972e 100644 --- a/staging/vhost-device-sound/src/audio_backends/alsa.rs +++ b/staging/vhost-device-sound/src/audio_backends/alsa.rs @@ -645,12 +645,14 @@ impl AudioBackend for AlsaBackend { } fn stop(&self, id: u32) -> CrateResult<()> { - if let Some(Err(err)) = self + if let Err(err) = self .streams .write() .unwrap() .get_mut(id as usize) - .map(|s| s.state.stop()) + .ok_or_else(|| Error::StreamWithIdNotFound(id))? + .state + .stop() { log::error!("Stream {} stop {}", id, err); }