PCM: Fix the invalid snd_pcm_close() calls in rate plugin

It happens in the error path, should call snd_pcm_free() instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2012-10-10 10:22:54 +02:00
parent a9f395e97c
commit 4bdb09126a

View file

@ -1394,13 +1394,13 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
} }
} else { } else {
SNDERR("Invalid type for rate converter"); SNDERR("Invalid type for rate converter");
snd_pcm_close(pcm); snd_pcm_free(pcm);
free(rate); free(rate);
return -EINVAL; return -EINVAL;
} }
if (err < 0) { if (err < 0) {
SNDERR("Cannot find rate converter"); SNDERR("Cannot find rate converter");
snd_pcm_close(pcm); snd_pcm_free(pcm);
free(rate); free(rate);
return -ENOENT; return -ENOENT;
} }
@ -1409,7 +1409,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
open_func = SND_PCM_RATE_PLUGIN_ENTRY(linear); open_func = SND_PCM_RATE_PLUGIN_ENTRY(linear);
err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops); err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops);
if (err < 0) { if (err < 0) {
snd_pcm_close(pcm); snd_pcm_free(pcm);
free(rate); free(rate);
return err; return err;
} }
@ -1418,7 +1418,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
if (! rate->ops.init || ! (rate->ops.convert || rate->ops.convert_s16) || if (! rate->ops.init || ! (rate->ops.convert || rate->ops.convert_s16) ||
! rate->ops.input_frames || ! rate->ops.output_frames) { ! rate->ops.input_frames || ! rate->ops.output_frames) {
SNDERR("Inproper rate plugin %s initialization", type); SNDERR("Inproper rate plugin %s initialization", type);
snd_pcm_close(pcm); snd_pcm_free(pcm);
free(rate); free(rate);
return err; return err;
} }