diff mbox

pcm: route: Correctly close slave pcm when no matching chmap is found

Message ID 1401177081-22204-1-git-send-email-david.henningsson@canonical.com (mailing list archive)
State Accepted
Delegated to: Takashi Iwai
Headers show

Commit Message

David Henningsson May 27, 2014, 7:51 a.m. UTC
This patch fixes a bug where the slave pcm was not correctly closed
on some error conditions, such as not finding a matching chmap.

Reported-by: Raymond Yau <superquad.vortex2@gmail.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
 src/pcm/pcm_route.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Takashi Iwai May 27, 2014, 9:39 a.m. UTC | #1
At Tue, 27 May 2014 09:51:21 +0200,
David Henningsson wrote:
> 
> This patch fixes a bug where the slave pcm was not correctly closed
> on some error conditions, such as not finding a matching chmap.
> 
> Reported-by: Raymond Yau <superquad.vortex2@gmail.com>
> Signed-off-by: David Henningsson <david.henningsson@canonical.com>

Thanks, applied.


Takashi

> ---
>  src/pcm/pcm_route.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
> index 49567ea..751e36f 100644
> --- a/src/pcm/pcm_route.c
> +++ b/src/pcm/pcm_route.c
> @@ -1429,8 +1429,10 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
>  	if (tt_chmap) {
>  		err = find_matching_chmap(spcm, tt_chmap, &chmap, &schannels);
>  		free(tt_chmap);
> -		if (err < 0)
> +		if (err < 0) {
> +			snd_pcm_close(spcm);
>  			return err;
> +		}
>  	}
>  
>  	err = _snd_pcm_route_determine_ttable(tt, &csize, &ssize, chmap);
> -- 
> 1.9.1
>
diff mbox

Patch

diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index 49567ea..751e36f 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -1429,8 +1429,10 @@  int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
 	if (tt_chmap) {
 		err = find_matching_chmap(spcm, tt_chmap, &chmap, &schannels);
 		free(tt_chmap);
-		if (err < 0)
+		if (err < 0) {
+			snd_pcm_close(spcm);
 			return err;
+		}
 	}
 
 	err = _snd_pcm_route_determine_ttable(tt, &csize, &ssize, chmap);