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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux