]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm_plug: Clear plugins on all error conditions
authorMichael Forney <mforney@mforney.org>
Thu, 20 Oct 2016 01:22:56 +0000 (18:22 -0700)
committerTakashi Iwai <tiwai@suse.de>
Thu, 20 Oct 2016 05:05:12 +0000 (07:05 +0200)
Otherwise, they will linger after the error is returned (but pcm->setup == 0).
Then, if the caller tries to clean up and call snd_pcm_close(), the assertion
plug->gen.slave == plug->req_slave will fail.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_plug.c

index 5639b9ea8044392dc4644b4e035fe2b4fecd0aa6..266707b425c19bc7c9ec8508765ef522317ed81f 100644 (file)
@@ -652,8 +652,10 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
               (plug->ttable && !plug->ttable_ok)) {
                snd_pcm_t *new;
                int err;
-               if (k >= sizeof(funcs)/sizeof(*funcs))
+               if (k >= sizeof(funcs)/sizeof(*funcs)) {
+                       snd_pcm_plug_clear(pcm);
                        return -EINVAL;
+               }
                err = funcs[k](pcm, &new, client, &p);
                if (err < 0) {
                        snd_pcm_plug_clear(pcm);