Fix leaks on multiple plugins
cover Fix leaks on multiple plugins
Hi all,
While I was working on AAF plugin RFC v2 series [1], I spotted several leaks in some plugins when handling *_hw_constraint() error cases. This series fixes these issues.
Regards,
Andre
[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2018-September/140290.html
Andre Guedes (4):
a52: Fix leaks when a52_set_hw_constraint() fails
jack: Fix leaks when jack_set_hw_constraint() fails
oss: Fix leaks when oss_hw_constraint() fails
usb_stream: Fix leaks when us_set_hw_constraint() fails
a52/pcm_a52.c | 2 +- jack/pcm_jack.c | 1 + oss/pcm_oss.c | 2 +- usb_stream/pcm_usb_stream.c | 1 + 4 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.14.4
PATCH 1/4 a52: Fix leaks when a52_set_hw_constraint() fails
If a52_set_hw_constraint() returns error, we leak 'rec' and 'rec->slave'. This patch fixes the issue by jumping to 'error' label where the proper clean up is already done.
--- a52/pcm_a52.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
a52/pcm_a52.c +1 -1
@@ -978,7 +978,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(a52)if ((err =a52_set_hw_constraint (rec)) <0 ) {snd_pcm_ioplug_delete (&rec->io); -return err; + goto error; } *pcmp = rec->io.pcm;
Signature · 1 line
2.14.4
PATCH 2/4 jack: Fix leaks when jack_set_hw_constraint() fails
In reply to Andre GuedesIf jack_set_hw_constraint() returns error, we leak the 'jack' object and all the resources referenced by it. This patch fixes the issue by calling snd_pcm_jack_free() before returning.
--- jack/pcm_jack.c | 1 + 1 file changed, 1 insertion(+)
jack/pcm_jack.c +1 -0
@@ -538,6 +538,7 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, err =jack_set_hw_constraint (jack);if (err <0 ) {snd_pcm_ioplug_delete (&jack->io); +snd_pcm_jack_free (jack);return err; }
Signature · 1 line
2.14.4
PATCH 3/4 oss: Fix leaks when oss_hw_constraint() fails
In reply to Andre GuedesIf oss_hw_constraint() returns error, we leak 'oss' object and all the resources referenced by it. This patch fixes the issue by jumping to 'error' label where the proper clean up is already done.
--- oss/pcm_oss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
oss/pcm_oss.c +1 -1
@@ -413,7 +413,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(oss)if ((err =oss_hw_constraint (oss)) <0 ) {snd_pcm_ioplug_delete (&oss->io); -return err; + goto error; } *pcmp = oss->io.pcm;
Signature · 1 line
2.14.4
PATCH 4/4 usb_stream: Fix leaks when us_set_hw_constraint() fails
In reply to Andre GuedesIf 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.
--- usb_stream/pcm_usb_stream.c | 1 + 1 file changed, 1 insertion(+)
usb_stream/pcm_usb_stream.c +1 -0
@@ -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; }
Signature · 1 line
2.14.4
Hi,
Quoted 16 lines · Andre Guedes
While I was working on AAF plugin RFC v2 series [1], I spotted several leaks in some plugins when handling
*_hw_constraint()error cases. This series fixes these issues.Regards,
Andre
[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2018-September/140290.html
Andre Guedes (4):
a52: Fix leaks whena52_set_hw_constraint()fails
jack: Fix leaks whenjack_set_hw_constraint()fails
oss: Fix leaks whenoss_hw_constraint()fails
usb_stream: Fix leaks whenus_set_hw_constraint()fails
Quoted 5 lines
a52/pcm_a52.c | 2 +- jack/pcm_jack.c | 1 + oss/pcm_oss.c | 2 +- usb_stream/pcm_usb_stream.c | 1 + 4 files changed, 4 insertions(+), 2 deletions(-)
I've reviewed all of the above patches.
I think it better for the plugins to use goto statement to aggregate error paths for releasing allocated objects but this is just for code cleanups.
Regards
Takashi Sakamoto
Takashi Iwai
AppliedQuoted 11 lines · Andre Guedes
Hi all,
While I was working on AAF plugin RFC v2 series [1], I spotted several leaks in some plugins when handling
*_hw_constraint()error cases. This series fixes these issues.Regards,
Andre
Quoted 7 lines
[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2018-September/140290.html
Andre Guedes (4):
a52: Fix leaks whena52_set_hw_constraint()fails
jack: Fix leaks whenjack_set_hw_constraint()fails
oss: Fix leaks whenoss_hw_constraint()fails
usb_stream: Fix leaks whenus_set_hw_constraint()fails
Applied all four patches now. Thanks.
Takashi