[alsa-devel] [PATCH - Multiple plugins 4/4] usb_stream: Fix leaks when us_set_hw_constraint() fails

Andre Guedes andre.guedes at intel.com
Fri Sep 28 23:27:27 CEST 2018


If us_set_hw_constraint() returns error, we leak the 'us' object and all
the resources referenced by it. This patch fixes the issue by calling
us_free() before returning.

Signed-off-by: Andre Guedes <andre.guedes at intel.com>
---
 usb_stream/pcm_usb_stream.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/usb_stream/pcm_usb_stream.c b/usb_stream/pcm_usb_stream.c
index 94c83a7..eb4ca98 100644
--- a/usb_stream/pcm_usb_stream.c
+++ b/usb_stream/pcm_usb_stream.c
@@ -455,6 +455,7 @@ static int snd_pcm_us_open(snd_pcm_t **pcmp, const char *name,
 	err = us_set_hw_constraint(us);
 	if (err < 0) {
 		snd_pcm_ioplug_delete(&us->io);
+		us_free(us);
 		return err;
 	}
 
-- 
2.14.4



More information about the Alsa-devel mailing list