]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
staging: speakup: fix synth caching when synth init fails
authorOkash Khawaja <okash.khawaja@gmail.com>
Tue, 20 Jun 2017 10:07:32 +0000 (11:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Jun 2017 14:31:22 +0000 (16:31 +0200)
synths[] array caches currently loaded synths. synth_add checks
synths[] before adding a new one. It however ignores the result of
do_synth_init. So when do_synth_init fails, the failed synth is still
cached. Since, as a result module loading fails too, synth_remove -
which is responsible for removing the cached synth - is never called.
Next time the failing synth is added again it succeeds because
synth_add finds it cached inside synths[].

This patch fixes this by caching a synth only after do_synth_init
succeeds.

Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/synth.c

index 703553916097b7ba1bceb2366d9b0406de265106..a1ca68c765792cd73034bb41e0ca18725db50d04 100644 (file)
@@ -445,10 +445,15 @@ int synth_add(struct spk_synth *in_synth)
                mutex_unlock(&spk_mutex);
                return -1;
        }
-       synths[i++] = in_synth;
-       synths[i] = NULL;
+
        if (in_synth->startup)
                status = do_synth_init(in_synth);
+
+       if (!status) {
+               synths[i++] = in_synth;
+               synths[i] = NULL;
+       }
+
        mutex_unlock(&spk_mutex);
        return status;
 }