summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-09-23 09:11:27 +0200
committerTakashi Iwai <tiwai@suse.de>2014-09-23 09:11:27 +0200
commit7c1f36dbcbe8d60c6f90cbcf7e2e801cacbcd535 (patch)
tree2d79d93659f2e5d06f504865cc50a1b0abd1b9ec
parentf78ba070b38c0711308d14ce642e78bc2a1a8fc6 (diff)
downloadalsa-lib-7c1f36dbcbe8d60c6f90cbcf7e2e801cacbcd535.tar.gz
mixer: Fix missing hctl handle free in snd_mixer_attach_hctl()
Yet another missing piece. Also, update the function document to warn about the behavior at error. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--src/mixer/mixer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index eee9875b..3a79c8e9 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -214,6 +214,8 @@ int snd_mixer_attach(snd_mixer_t *mixer, const char *name)
* \param mixer Mixer handle
* \param hctl the HCTL to be attached
* \return 0 on success otherwise a negative error code
+ *
+ * Upon error, this function closes the given hctl handle automatically.
*/
int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
{
@@ -222,8 +224,10 @@ int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
assert(hctl);
slave = calloc(1, sizeof(*slave));
- if (slave == NULL)
+ if (slave == NULL) {
+ snd_hctl_close(hctl);
return -ENOMEM;
+ }
err = snd_hctl_nonblock(hctl, 1);
if (err < 0) {
snd_hctl_close(hctl);